2017-04-08 111 views
0

我需要从临时位置移动上传的图像。在Laravel中移动上传的文件5.3

上传临时图像的路径如下所示:

/storage/tmp/posts/14916460012147460153.jpg

要移动图像我使用存储::移动()门面。

$__fn = basename($tmpImage); 
    Storage::move( 
    storage_path('app') . '/public/tmp/posts/' . $__fn, 
    storage_path('app') . '/public/images/'.Auth::id().'/posts/' . $__fn 
); 

但它抛出一个错误:虽然该文件存在,可以通过浏览器在本地主机中找到

FileNotFoundException in Filesystem.php line 385:

File not found at path: D:\Projects\expo\storage\app/public/tmp/posts/14916460012147460153.jpg

:8000 /存储/ tmp目录/职位/ 14916460012147460153.jpg

我读文档laravel filesystem,但不能理解这里缺少的东西。

+0

确保该文件存在'd:\项目\博览会\存储\应用程序/公共的/ tmp /职位/ 14916460012147460153.jpg'! –

+0

@IsmailRBOUH是的文件存在,可以通过浏览器找到http:// localhost:8000/storage/tmp/posts/14916460012147460153.jpg – rakibtg

+1

请尝试'Storage :: disk('public') - > move('tmp/posts /'。$ __ fn','images /'。Auth :: id()。'/ posts /'。$ __ fn);' –

回答

1

请尽量使用替代Storage外观和绝对路径磁盘实例:

Storage::disk('public')->move(
    'tmp/posts/' . $__fn, 
    'images/'. Auth::id() . '/posts/' . $__fn);