Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP / CodeIgniter - $_FILES being ignored completely

I have the following in my view

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

In my controller, i have the following code.

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

Fairly simple yes? .... Except that every time i run it, no matter if i have choosen a file or not, it runs ... Should it only run the echo if i have a file ready for input?

like image 647
Chris Avatar asked Apr 08 '26 02:04

Chris


2 Answers

Make sure your FORM element has the following attributes:

method="POST"

and

enctype="multipart/form-data"

  • Christian
like image 191
Christian Joudrey Avatar answered Apr 09 '26 16:04

Christian Joudrey


check your PHP.ini for:

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

do a phpinfo();

disclaimer php.ini values might be slightly off, but you'll find them I'm sure. the names are right, not sure if the values are.

like image 35
Ross Avatar answered Apr 09 '26 15:04

Ross