I've built a hundred file upload programs using PHP but for some reason on the current hosting account the upload isn't working. The problem is that when I send the file, the $_FILES array is empty. It sends all the $_POST data correctly. I queried the hosting support about this and they suggested I turn register globals on which didn't solve the problem. This also indicates to me that it's not something the hosting providers have disallowed. For those of you who want to query my code I've pasted it in below; // Form posting the file <form action = 'products.php?add=1' method = 'POST' enctype='multipart/form-data'> <input type='file' name='datasheet' /> <br /><br /> <input type='submit' value='submit' /> </form> PHP: // Handling the posted data $datasheet_path = $target_path . "datasheets/"; $name_arr = explode(".",$_FILES['datasheet']['name']); $datasheet = $name_arr[0] . "-" . $timestamp . "." . $name_arr[1]; $datasheet_target = $datasheet_path . $datasheet; move_uploaded_file($_FILES['datasheet']['tmp_name'], $datasheet_target); PHP:
Okay, I've finally figured out what the problem was. The file I was uploading had spaces in it which was confusing it. Weird!! Other problems I found that other people had were; - Not including the enctype section - Not including the proper quotations around the enctype section - Having the file_uploads set to off in the server settings or PHP.INI file - Having the max file size too low for the files you are uploading - Wrong permissions set on the file you are uploading too