简体   繁体   English

Laravel:图片和视频未更新

[英]Laravel: Images and Videos are not updating

I am using Laravel 5.5, and I have problems to update images and videos. 我正在使用Laravel 5.5,并且在更新图像和视频时遇到问题。 The thing here is that I have an index of my videos, these videos are being uploades to a folder (\\storage\\app\\public\\videos) this path has been linked whith the command: 这里的事情是我有我的视频的索引,这些视频正在被上传到一个文件夹(\\ storage \\ app \\ public \\ videos),该路径已通过以下命令链接:

php artisan storage:link

I have no problem storing any file, I use the following code on my controller: 我没有存储任何文件的问题,我在控制器上使用了以下代码:

$videoName = "".$request->user."_".$request->propiedad."_".$videoNumber.".mp4";

$request->video->storeAs('public/videos', $videoName);

As I said everything works fine, but if I try to update this file, I save it with the same name using the same code: 正如我所说的,一切正常,但是如果我尝试更新此文件,则使用相同的代码将其保存为相同的名称:

$request->video->storeAs('public/videos', $videoName);

And it saves when i check the folder, but the view displays the old video instead of the new one, i am not sure what is going on I have tried to clear cache but is not working. 当我检查文件夹时,它可以保存,但是视图显示的是旧视频而不是新视频,我不确定发生了什么,我试图清除缓存,但无法正常工作。

Check if the file exist. 检查文件是否存在。 if yes, then delete it and upload the new one. 如果是,则将其删除并上传新的。

$videoName = "".$request->user."_".$request->propiedad."_".$videoNumber.".mp4";

if(Storage::exists('public/videos' . $videoName)) {
    Storage::delete('public/videos' . $videoName);
}

// Save the video
$request->video->storeAs('public/videos', $videoName);

Deleting a file 删除文件

Checking if the file exists 检查文件是否存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM