$destinationPath = public_path().'/uploads/';
if (Input::hasFile('photo'))
{
$res = Input::file('photo')->move($destinationPath);
echo $destinationPath;
if($res)
{
echo '<br />good';
}
else
{
echo 'bad'.$res;
}
exit;
}
我的enctype表单是enctype="multipart/form-data"
,uploads文件夹存在且访问权限为777
,上面的语句返回good
,路径是否正确,我做错了什么?< / p>
答案 0 :(得分:0)
$photo = Input::file('photo');
if (Input::hasFile('photo'))
{
$file = Input::file('photo');
$destinationPath = public_path().'/uploads/';
$filename = $file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
$user->logo_path = $filename;
}
$object->save();
//不要忘记使用保存功能保存它,否则你的辛勤工作将一无所有
// $ object:使用像user,car这样的对象......