我处于一个非常奇怪的情况:
当我尝试使用上传一些文件时,Form::file('image')
我只得到空值。
表格
{{ Form::open(['route' => 'admin.companies.store', 'class' => 'form', 'files' => true]) }}
<h3>{{ trans('messages.companies.data_company') }}</h3>
<div class="form-group">
{{ Form::label('image', trans('messages.companies.image')) }}
<div class="row">
<div class="col-xs-4">
{{ Form::file('image') }}
@include ('partials.validator_field', ['field' => 'image'])
</div>
</div>
</div>
nginx
首先,我尝试验证我的 nginx 配置,但显然没问题。
server {
listen 80;
server_name www.example.com.build example.com.build;
access_log /var/www/customers/example/logs/access.log;
error_log /var/www/customers/example/logs/error.log;
root /var/www/customers/example/example/public;
client_max_body_size 100m;
location / {
sendfile on;
client_max_body_size 200m;
try_files $uri $uri/ /index.php$is_args$args;
index index.html index.htm index.php;
}
location ~ \.php$ {
include /usr/local/etc/nginx/fastcgi_params;
try_files $uri /index.php =404;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/customers/example/example/public$fastcgi_script_name;
fastcgi_param debug true;
}
}
权限
然后我尝试授予777权限app/storage
,public/images
并且public/upload
(我正在使用干预/图像上传包):同样的错误,没有任何变化。
奇怪的测试
我测试了这样的“纯输入文件”<input type="file" name="teste />
并且上传工作:PHP已收到图像。
最终输出(var_dump)
$_FILES
array(1) {
["image"]=>
array(5) {
["name"]=>
string(0) ""
["type"]=>
string(0) ""
["tmp_name"]=>
string(0) ""
["error"]=>
int(4)
["size"]=>
int(0)
}
}
Input::file('image')
NULL
Input::all()
array(31) {
["_token"]=>
string(40) "GDaT0jqKmpmDyGw4BeRVW1tCb01T1ni5gvKoKCPg"
["name"]=>
string(4) "tste"
["description"]=>
string(0) ""
["corporate_name"]=>
string(0) ""
["company_segment_id"]=>
string(1) "4"
["company_relationship_id"]=>
string(1) "2"
["contract"]=>
string(0) ""
["state_registration"]=>
string(0) ""
["cnpj"]=>
string(0) ""
["cnae_session"]=>
string(0) ""
["address"]=>
string(0) ""
["street"]=>
string(0) ""
["street_number"]=>
string(0) ""
["street_complement"]=>
string(0) ""
["postalcode"]=>
string(0) ""
["neighborhood"]=>
string(0) ""
["state_id"]=>
string(1) "1"
["city_id"]=>
string(0) ""
["landmark"]=>
string(0) ""
["phone_comercial"]=>
string(0) ""
["phone_fax"]=>
string(0) ""
["phone_mobile_1"]=>
string(0) ""
["phone_mobile_2"]=>
string(0) ""
["site"]=>
string(0) ""
["skype"]=>
string(0) ""
["facebook"]=>
string(0) ""
["linkedin"]=>
string(0) ""
["youtube_channel"]=>
string(0) ""
["informations"]=>
string(0) ""
["active"]=>
string(2) "on"
["image"]=>
NULL
}
信息
Nginx 版本:nginx/1.6.2
PHP 5.6.6 (cli)(构建时间:2015 年 3 月 9 日 00:40:37)版权所有 (c) 1997-2015 PHP Group Zend Engine v2.6.0,版权所有 (c) 1998-2015 Zend Technologies
Mac OS 优胜美地
这是我第一个使用 nginx 的项目。
对不起我的英语不好。