【发布时间】:2015-04-19 19:44:18
【问题描述】:
为了简单起见,我认为:
{{ Form::open(['route' => 'files', 'method' => 'POST', 'files' => 'true']) }}
{{ Form::file('file') }}
{{ Form::submit(); }}
{{ Form::close() }}
在我的控制器中:
return Response::json([$_FILES, print_r(Input::file('file'),1)]);
这是我提交时得到的回复:
[
{
"file": {
"name": "sample.jpg",
"type": "image/jpeg",
"tmp_name": "/tmp/phpItZT7K",
"error": 0,
"size": 17645
}
},
{}
]
我在搜索时遇到的唯一真正的解决方案是 enctype,我通过 Form::open 中的 'files' 属性在我的表单上拥有它。在这一点上,我不知道发生了什么。它不会破坏应用程序,但它仍然很烦人。如果有人能对此有所了解,我会非常高兴。
【问题讨论】:
-
您面临的问题是什么...??
-
Input::file() 没有返回任何数据。没有 UploadedFile 对象或任何东西。从那以后,它在两次刷新之间神奇地重新开始工作,而我没有更改任何相关的代码,或者我相信。
-
我们遇到了同样的问题。 $_FILES 显示了一个包含文件的数组,但 Input::file('file') 没有显示任何内容。
标签: php laravel file-upload laravel-4