Laravel - 发布网站后图像源不可读
Laravel - Image source not readable after publish website
我创建了简单的 CMS,一切都在本地主机上运行。发布网站后我无法上传图片。我有一个错误 "Image source not readable"。我将 chmod upload 的文件夹更改为 777。
我的代码:
$minphoto_path = 'uploads/img';
$minphoto = $request->minphoto;
$minphoto_new_name = time().$minphoto->getClientOriginalName();
$minphoto->move($minphoto_path, $minphoto_new_name);
$img = Image::make(public_path($minphoto_path . '/' .$minphoto_new_name))->resize(240, 338)->save(public_path($minphoto_path . '/' .$minphoto_new_name));
尝试以这种方式上传:
$file = Input::file('file');
$fileName = time() . '-' . $file->getClientOriginalName();
$file->move('uploads', $fileName);
$img = Image::make($file->getRealPath())->resize(320, 240)
->save('public/uploads/'. $file->getClientOriginalName());
或更短:
$file = Input::file('file');
$img = Image::make($file)->resize(320, 240)
->save('public/uploads/'. $file->getClientOriginalName());
我创建了简单的 CMS,一切都在本地主机上运行。发布网站后我无法上传图片。我有一个错误 "Image source not readable"。我将 chmod upload 的文件夹更改为 777。 我的代码:
$minphoto_path = 'uploads/img';
$minphoto = $request->minphoto;
$minphoto_new_name = time().$minphoto->getClientOriginalName();
$minphoto->move($minphoto_path, $minphoto_new_name);
$img = Image::make(public_path($minphoto_path . '/' .$minphoto_new_name))->resize(240, 338)->save(public_path($minphoto_path . '/' .$minphoto_new_name));
尝试以这种方式上传:
$file = Input::file('file');
$fileName = time() . '-' . $file->getClientOriginalName();
$file->move('uploads', $fileName);
$img = Image::make($file->getRealPath())->resize(320, 240)
->save('public/uploads/'. $file->getClientOriginalName());
或更短:
$file = Input::file('file');
$img = Image::make($file)->resize(320, 240)
->save('public/uploads/'. $file->getClientOriginalName());