我遇到与这个人相同的错误:
基本上我的错误是将图像上传到特定路径,我的代码如下:
public function postCreate() {
$validator = Validator::make(Input::all() , Product::$rules);
if ($validator->passes()) {
$product = new Product;
$product->category_id = Input::get('category_id');
$product->title = Input::get('title');
$product->description = Input::get('description');
$product->price = Input::get('price');
$image = Input::file('image');
$filename = date('Y-m-d-H:i:s')."-".$image->getClientOriginalName();
Image::make($image->getRealPath())->resize(468, 249)->save('public/img/products'.$filename);
$product->image = 'public/img/products'.$filename;
$product->save();
return Redirect::to('admin/products/index')
->with('message' , 'Product created');
}
return Redirect::to('admin/products/index')->with('message' , 'something went wrong')
->withErrors($validator)->withInput();
}
我只是想遵循有关laravel电子商务Web应用程序的教程。
我想问题是我的目录中没有写权限,如何在目录中添加写权限。IE公用文件夹,我用Google搜索了几个地方,但是我不知道我必须编辑什么?
IE浏览器的htaccesss文件或我可以在cmd上进行写更改吗?还有如何检查目录在什么天气下受到写保护。
PS。我正在使用Windows。我附上错误的屏幕截图。
谢谢你。
您可能要更改日期格式,因为Windows不允许在文件名中使用冒号:
$filename = date('Y-m-d-H:i:s')."-".$image->getClientOriginalName();
而且您可能还想在路径中添加斜杠,以免将文件名连接到文件夹路径:
Image::make($image->getRealPath())->resize(468, 249)->save('public/img/products'.$filename);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句