【发布时间】:2018-04-17 00:24:08
【问题描述】:
我用上传图片制作输入数据,我的代码
$name = $request->input('name');
$images = $request->file('image');
$name_img = $images->getClientOriginalName();
$ext = $images->getClientOriginalExtension();
// Move Uploaded File
$destinationPath = 'img/';
$images->move($destinationPath,$name_img);
$path = $destinationPath.'/'.$name_img;
然后将它们放入数组中,然后插入数据库中
$data = array(
'name' => $name,
'image' => $path, );
DB::table('daftar')->insert($data);
return json_encode(array('status' =>true));
该代码在 Laravel 5.1 中有效,但在 Laravel 5.2 中无效。
Laravel 5.2 的代码有什么问题吗?
谢谢。 :)
【问题讨论】:
-
为什么有 2 个斜线?一个在
'img/',一个在$path = $destinationPath.'/'.$name_img;? -
我的意思是'img',没有斜线。
标签: php file-upload laravel-5.2 laravel-5.1 image-uploading