Pacopag Posted February 15, 2011 Share Posted February 15, 2011 Hi. This is my first post, so feel free to lecture me on forum etiquette and conventions. I'm trying to create a form, several items of which are file upload <input>s. Here is the relevant code from the form. <label for="facefile">Filename:</label> <input type="file" name="facefile" id="facefile" /> This form has an action="validateform.php". In the file for validateform.php I can't seem to reference "facefile". I just try doing <?php echo($_FILES["facefile"]["name"]); ?> And I get Notice: Undefined index: facefile in validateform.php on line 1 Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/ Share on other sites More sharing options...
Pikachu2000 Posted February 15, 2011 Share Posted February 15, 2011 Does the <form> tag also have a enctype="multipart/form-data" attribute? Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174354 Share on other sites More sharing options...
Pacopag Posted February 15, 2011 Author Share Posted February 15, 2011 Yes. the form tag is <form enctype="multipart/form-data" action="validateform.php" name="profileForm" method="get"> Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174355 Share on other sites More sharing options...
Pacopag Posted February 15, 2011 Author Share Posted February 15, 2011 The code seems so transparent that I think that there must be a problem with something other than the code. Maybe Apache is not configured right? I've seen similar posts to this where the poster said it was a problem with php.ini. But he didn't give any details. Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174368 Share on other sites More sharing options...
Pikachu2000 Posted February 15, 2011 Share Posted February 15, 2011 Add the following and post the output after the form has been submitted. echo 'POST array:<pre>'; print_r($_POST); echo '</pre>FILES array:<pre>'; print_r($_FILES); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174375 Share on other sites More sharing options...
PFMaBiSmAd Posted February 15, 2011 Share Posted February 15, 2011 You have got to use the post method to upload files - method="post" Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174379 Share on other sites More sharing options...
Pacopag Posted February 15, 2011 Author Share Posted February 15, 2011 Excellent! Thanks so much. The fix was to change method to "post". Quote Link to comment https://forums.phpfreaks.com/topic/227699-trouble-uploading-files-notice-undefined-index/#findComment-1174523 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.