0

I'm in a very strange situation:

When I try to upload some file using Form::file('image') I get only null value.

the form

{{ 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

First I try to verify my nginx configuration but apparently it's ok.

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;
    }
}

permissions

Then I try to give 777 permission to app/storage, public/images and public/upload (I'm using intervention/image upload package): same error, nothings change.


strange test

I test put a "pure input file" like that <input type="file" name="teste /> and the upload works: PHP has received the image.


the final output (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
}

infos

Nginx version: nginx/1.6.2

PHP 5.6.6 (cli) (built: Mar 9 2015 00:40:37) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

Mac OS Yosemite


It's my first project using nginx.

Sorry for my english.

Community
  • 1
  • 1
Patrick Maciel
  • 4,874
  • 8
  • 40
  • 80

2 Answers2

0

Can you try it with removing this part:

@include ('partials.validator_field', ['field' => 'image'])

You've already opened an image input. What's this part for ?

mirza
  • 5,685
  • 10
  • 43
  • 73
0

Checking all fields of that form I found another field with the same name.

Newbie problem.

Thanks guys.

Patrick Maciel
  • 4,874
  • 8
  • 40
  • 80