dtayler Posted April 7, 2006 Share Posted April 7, 2006 I am having a problem with accessing the $_FILES array. I find that it sometimes has data in, and sometimes is empty! (I have to submit the first file, go back, submit again....several times, and then will get data) I am running Apache locally, and have checked the php settings for max file size, upload allowed, global variables etc., as recommended in the articles I've found on this. My code is in two php files as given below. PLEASE can somebody help.upload.phphtml><head></head><body><form enctype="multipart/form-data" method="post" action="upload2.php" ><input type="file" name="newname"><input type="submit"></form></body></html>upload2.phphtml><head></head><body><?phpecho '<br> Files contains: name :'.$_FILES['newname']['name'].' temp :'.$_FILES['newname']['tmp_name'].' type :'.$_FILES['newname']['type'].' size :'.$_FILES['newname']['size'].' error :'.$_FILES['newname']['error'].'<br>';?></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/6803-uploading-files/ Share on other sites More sharing options...
kenrbnsn Posted April 7, 2006 Share Posted April 7, 2006 Change you test to be the following and see if you have the same problem:[code]<?phpif (isset($_POST['submit'])) echo '<pre>' . print_r($_FILES,true) . '</pre>';?><html><head></head><body><form enctype="multipart/form-data" method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" ><input type="file" name="newname"><br><input type="submit" name="submit" value="Upload File"></form></body></html>[/code]With this code you don't have to hit the "back" button to get back to the form and the dump the $_FILES array is nicely formatted.Ken Quote Link to comment https://forums.phpfreaks.com/topic/6803-uploading-files/#findComment-24739 Share on other sites More sharing options...
dtayler Posted April 7, 2006 Author Share Posted April 7, 2006 [!--quoteo(post=362510:date=Apr 7 2006, 08:36 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 7 2006, 08:36 AM) [snapback]362510[/snapback][/div][div class=\'quotemain\'][!--quotec--]Change you test to be the following and see if you have the same problem:[code]<?phpif (isset($_POST['submit'])) echo '<pre>' . print_r($_FILES,true) . '</pre>';?><html><head></head><body><form enctype="multipart/form-data" method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" ><input type="file" name="newname"><br><input type="submit" name="submit" value="Upload File"></form></body></html>[/code]With this code you don't have to hit the "back" button to get back to the form and the dump the $_FILES array is nicely formatted.Ken[/quote]Thanks Ken, it's easier than going back a page all the time - but I still get the same problem!Deb Quote Link to comment https://forums.phpfreaks.com/topic/6803-uploading-files/#findComment-24752 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.