【发布时间】:2013-05-14 04:41:18
【问题描述】:
我正在尝试制作一个允许上传文件并将其存储在应用程序的 public/upload 文件夹中的表单。
我的表格是:
<form action="/image/save" method="post">
<input name="image" type="file" />
<input type="submit" value="Save"/>
</form>
和控制器:
public function save(){
$file = Input::file('image');
$destinationPath = 'upload/';
$filename = $file->getClientOriginalName();
Input::file('image')->move($destinationPath, $filename);
但是当我运行它时,我收到以下错误:
在非对象上调用成员函数getClientOriginalName()
【问题讨论】:
-
您正在使用 $file->getClientOriginalName()。它与 $file 无关
标签: php frameworks laravel laravel-4