views:

163

answers:

3

When I am going to upload a file, my $_POST variable knows the file name, but the $_FILES variable is null. I've used this code before, so I'm really stumped.

Here's what I'm using for input:

<label for="importFile">Attach Resume:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<input type="file" name="importFile" id="importFile" class="validate['required']">

And for processing:

$uploaddir = "E:/Sites/OPL/2008/assets/apps/newjobs/resumes/";
$uploadfile = $uploaddir . time() . '-' . urlencode(basename($_FILES['importFile']['name']));

if (!move_uploaded_file($_FILES['importFile']['tmp_name'], $uploadfile)) {
    echo 'Error uploading file. Error number: ' . $_FILES['importFile']['error'];
    var_dump($_FILES['importFile']);
    echo $_POST['importFile'];
    die();
}

Which is giving me this result:

Error uploading file. Error number: NULL
Maintaining The OPL Website.doc

Any help would be greatly appreciated.

+1  A: 

Have you set the enctype attribute of your form tag to multipart/form-data? It should read

<form enctype="multipart/form-data" ...
soulmerge
+2  A: 

Does the form tag have the enctype='multipart/form-data' attribute?

jasonbar
+4  A: 

i'm not sure but first check if form contains

 enctype="multipart/form-data"

second check whats in $_FILES at all , i'm not sure if the $_FILES['importFile'] is right sintax ... i think it doesnt contain the name

Nexum