PHP / CodeIgniter - $ _FILES ignored completely

I have the following in my opinion

<input class="file" name="mpfile[]" type="file" size="32" />

In my controller, I have the following code.

if(isset($_FILES['mpfile'])) {
    echo 'testing';
}

Pretty simple huh? .... Except that every time I run it, regardless of whether I selected a file or not, it starts ... If it runs only an echo, if I have a file ready for input?

+3
source share
9 answers

Make sure your FORM element has the following attributes:

method="POST"

and

enctype="multipart/form-data"

  • Christian
+8
source

check your php.ini for:

file_uploads = "1"
post_max_size = 50000
upload_max_file_size = 2M

do a phpinfo();

Disclaimer Php.ini values ​​may be slightly disabled, but you will find them, I'm sure. the names are correct, not sure if these values ​​are.

+2
source
  if(isset($_FILES['mpfile']['name']) && $_FILES['mpfile']['name'])
  {
    echo 'testing';
   }
0

, <input> <form>, POST script, $_FILES? :.

if ('POST' == $_SERVER['REQUEST_METHOD'])
  {
     print '<pre>'.var_export($_FILES,TRUE).'</pre>';
  }

? , PHP?

0

Codeigniter. Codeigniter $_FILES .

, $_FILES codeigniters index.php, ,

0

. :

if($_FILES['mpfile']['error'] != UPLOAD_ERR_NO_FILE) {
     echo 'testing'; 
}
0

:

if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] != 4)

:

http://codeigniter.com/forums/viewthread/136610/#673652

" $_FILES, , 4 0 .

:

, , ['mpfile'] ['userfile']

0
if (!empty($_FILES['mpfile']['name'])) {
    var_dump($_FILES['mpfile']['name']);
}
0

You define an array:

<input class="file" name="mpfile[]" type="file" size="32" />

In PHP, a variable $_FILES['mpfile']will also be an (empty) array. If you are testing with now isset, then it is installed because it is an array (and never null).

Test with empty().

0
source

Source: https://habr.com/ru/post/1778159/


All Articles