dynomonkey Posted October 12, 2006 Share Posted October 12, 2006 Hi everyone,Ive been working on a simple system that allows files to be uploaded to my server and I'm having problems receiving the $_POST and $_FILES variables from my form. It appears the POST method isnt working for sum reason. here is my code:<form action="procnewsletter.php" method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td>Title: </td> <td><input type="text" name="title"></td> </tr> <tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" class="box" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value="Upload"></td> </tr> </table> </form> And the proccessing page (procnewsletter.php) does the following:<?$title = $_POST['title'];echo $title;$uploadDir = 'Files/Newsletters/'; if (!is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo "You did not upload a file!"; } $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; if(move_uploaded_file($tmpName, $filePath)) { echo "The file has been uploaded";} else{ echo "There was an error uploading the file, please try again!";} ?>I always receive the "You did not upload a file!" error, and nothing is stored in the variables i created. This is because nothing seems to be passed in the header when using POST method. so I cant retreive any of the information entered in the form. IF i remove method="post" from the form then i can get the title using $_REQUEST['title] but i still dont get anything in the $_FILES array.Any help would be much much much appreciated.Thank you very much. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 12, 2006 Share Posted October 12, 2006 I copied your script to my server where it ran fine. Put these lines at the start of the processing script:[code]<?phpecho '<pre> --- $_POST --- ' . print_r($_POST,true) . '</pre>';echo '<pre> --- $_FILES --- ' . print_r($_FILES,true) . '</pre>';?>[/code]This will dump what the script is recieving from the form and may give you a hint as to what is wrong.Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.