图像不会在文件夹路径上移动 [英] Image dose not move at folder path
本文介绍了图像不会在文件夹路径上移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经给images
文件夹提供了777 permission
. Charts Table
还将保存图像的所有记录.我将在此处附加表:charts
结构.
I already given 777 permission
to my images
folder. Charts Table
is also saving all record of image. I am going to attach table:charts
structure here.
public function store(Request $request)
{
$input = $request->all();
$tradeID= Auth::user()->trade()->create($input);
if($file = $request->file('file'))
{
$name = time() . $file->getClientOriginalName();
$file->move('images', $name);
$photo = Chart::create(['file'=>$name]);
$input['photo_id'] = $photo->id;
}
$tradeID->chart()->create($input);
}
推荐答案
尝试将目标路径从相对路径更改为绝对路径
Try to change destination path from relative to absolute
public function store(Request $request)
{
$input = $request->all();
$tradeID= Auth::user()->trade()->create($input);
if($file = $request->file('file'))
{
$name = time() . $file->getClientOriginalName();
$file->move( public_path() . '/images/', $name); // absolute destination path
$photo = Chart::create(['file'=>$name]);
$input['photo_id'] = $photo->id;
}
$tradeID->chart()->create($input);
}
这篇关于图像不会在文件夹路径上移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文