如何在默认的Laravel注册控制器上获取文件上传的详细信息

huangapple go评论74阅读模式
英文:

how to get fileupload details on default laravel controller of register

问题

我从注册表单上传文件,但在注册控制器中没有获取到$_FILES的详细信息。我想要temp_name和文件名,但我只能获取到文件名。注册控制器以数组数据的形式获取值。

您能帮助解决这个问题吗?

$pathoffile = $_FILES['boxfile1']['tmp_name'];
$filename = $_FILES['boxfile1']['name'];
英文:

I upload file from register form, but I didn't get details of $_FILES on register controller. I want temp_name and filename I will get name of the file only. register controller get values as array data.

Can you please help with this issue.

$pathoffile=$_FILES['boxfile1']['tmp_name'];
$filename=$_FILES['boxfile1']['name'];

答案1

得分: 1

你需要设置表单属性 enctype="multipart/form-data"

在 Laravel 中,你可以通过以下方式实现:{{Form::open(array('url' => 'your_url', 'method' => 'post', 'files' => true))}}

参考链接:https://stackoverflow.com/questions/39344259/laravel-5-1-form-files-true

英文:

You need to set form attribute enctype="multipart/form-data"

In Laravel you can do this by {{Form::open(array('url' => 'your_url', 'method' => 'post', 'files' => true))}}

Reference: https://stackoverflow.com/questions/39344259/laravel-5-1-form-files-true

huangapple
  • 本文由 发表于 2020年1月3日 15:55:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/59575003.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定