Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_FILES Not Working?

Tags:

html

php

I am submitting files via this way, inside of a form (with a submit button, form tags, etc):

<fieldset>
        <input type="file" name="file" />
    </fieldset>

And I am trying to pull it/use it with PHP this way:

$file = $orgname."/".basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $file);

And I am getting these errors:

Notice: Undefined index: file in C:\wamp\www\generic\addorg.php on line 45

Notice: Undefined index: file in C:\wamp\www\generic\addorg.php on line 46

What could be causing this? Everything I've looked into suggests it should work.

like image 750
Ryan Schafer Avatar asked Nov 23 '11 17:11

Ryan Schafer


2 Answers

form needs to be set enctype=multipart/form-data

like image 127
Tusk Avatar answered Nov 04 '22 20:11

Tusk


Make sure your <form... specifies enctype="multipart/form-data">

like image 6
djdy Avatar answered Nov 04 '22 20:11

djdy