我在将“cover\u image”迁移到phpmyAdmin时遇到问题。每次我尝试上传照片时,都会出现一个错误:
SQLSTATE[42S22]:未找到列:“字段列表”中的1054未知列“cover\u images”
下面是我的代码:
if($request->hasFile('cover_image')) {
//get``
$fileNameWithExt = $request->file('cover_image')->getClientOriginalName();
//get filename
$filename = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
//get ext
$extension = $request->file('cover_image')->getClientOriginalExtension();
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//upload image
$path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore);
} else {
$fileNameToStore = 'noimage.jpg';
}
//Create Post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->user_id = auth()->user()->id;
$post->cover_images = $fileNameToStore;
$post->save();
return redirect('/posts')->with('success', 'Post Created');