abazoskib Posted October 7, 2009 Share Posted October 7, 2009 ok so im doing something really simple and i cant get why its not working. i am trying to upload a file to a folder with proper permissions. i have the form and the process code on the same page: /////////////// //PROCESS UPLOADED FILE /////////////// if(isset($_POST['processFile'])) { $target_path = "/home/content/c/j/o/cjoday/camPanel/uploads/"; $target_path = $target_path . basename( $_FILES['uploaded']['name']); $temp_path = $_FILES['uploaded']['tmp_name']; if(move_uploaded_file($temp_path, $target_path)) { //file uploaded } else{ //file not uploaded } } <form enctype="multipart/form-data" method="post"> Or upload a new a file: <input name="uploaded" type="file" /><br /> <input type="submit" name="processFile" value="Process File" /> </form> print_r($_FILES) returns an empty array and I keep getting an error: Notice: Undefined index: uploaded in Panel/utilities.php on line 54 Notice: Undefined index: uploaded in Panel/utilities.php on line 55 ive searched everywhere but all the answers point to not having the enctype attribut of the form. Quote Link to comment https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2009 Share Posted October 7, 2009 If $_POST['processFile'] is set, but the $_FILES array is empty, it is likely that uploads are not enabled on your server. What does a phpinfo(); statement show for the file_uploads setting? Quote Link to comment https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/#findComment-932663 Share on other sites More sharing options...
abazoskib Posted October 7, 2009 Author Share Posted October 7, 2009 I htought the same thing, and file uploads are ON. Quote Link to comment https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/#findComment-932670 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2009 Share Posted October 7, 2009 If the line numbers mentioned in the errors you posted corresponds to the code that is inside of the if(isset($_POST['processFile'])) { logic, then it is likely that your code is overwriting the $_FILES array. Another possibility would be invalid nested form tags. You would need to post your actual code for someone to be able to determine which out of the several possible reasons it is not working. Quote Link to comment https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/#findComment-932676 Share on other sites More sharing options...
abazoskib Posted October 8, 2009 Author Share Posted October 8, 2009 it was indeed poorly formed form elements. thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/#findComment-932831 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.