我的代码在localhost上工作得非常好,我改变了.htaccess。
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M
控制器代码如下。给定代码发送数据库内的所有数据,如图像名称和扩展名,每个和一切工作正常,但图像不会被上传到相应的文件夹。
public function store(Request $request)
{
// Validate Data
$this->validate($request, [
'member' => 'required|max:255',
'specialized' => 'required|max:255',
'image' => 'image',
]);
//Store Data
$team = new Team;
$team -> member = $request->member;
$team -> specialized = $request->specialized;
$team -> designation = $request->designation;
if($request->hasFile('image')){
$image = $request->file('image');
$filename = time() . '.' . $image->getClientOriginalExtension();
$location = storage_path('/app/public/images/' . $filename);
Image::make($image)->resize(400, 500)->save($location);
$team -> image = $filename;
}
if($team->save()){
Session::flash('success', 'Team Member Added Successfully');
return redirect()->route('team.index', $team->id);
} else{
Session::flash('error', 'Sorry a problem occurred while adding Team Member');
return redirect()->route('team.create');
}
}
甚至跟随带有属性的表单标记
<form method="POST" action="{{route('team.store')}}" accept-charset="UTF-8" enctype="multipart/form-data">
请帮我解决这个问题。
答案 0 :(得分:0)
将权限755授予存储目录
答案 1 :(得分:0)
授予权限755到哪个目录你已经上传了图像文件,或者如果你的php代码主机在nginx服务器上然后在nginx.conf上更新nginx配置添加或更新这一行
client_max_body_size 100M;