dennismonsewicz Posted April 15, 2008 Share Posted April 15, 2008 $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $_FILES['uploadedfile']['tmp_name']; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } my code above does not work, any help? Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/ Share on other sites More sharing options...
craygo Posted April 15, 2008 Share Posted April 15, 2008 Any errors?? Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517925 Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Author Share Posted April 15, 2008 no, it just displays there was an error uploading the file... Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517927 Share on other sites More sharing options...
craygo Posted April 15, 2008 Share Posted April 15, 2008 what does your form look like to upload the file?? Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517929 Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Author Share Posted April 15, 2008 Well its A LOT of code, cause I am modifying a calendar script to include an upload. It is about 900 lines of code. I wouldn't want you to bore yourself to death with 900 lines lol. I don't understand why the script isn't working though everything is set the way that it should be Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517940 Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Author Share Posted April 15, 2008 here is my input code: echo "Add a file? <input type='file' name='uploadedfile'>"; Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517943 Share on other sites More sharing options...
craygo Posted April 15, 2008 Share Posted April 15, 2008 reason i was asking is you need to make sure the form is multipart. <form action="" method="post" enctype="multipart/form-data"> Otherwise file uploads won't work Ray Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517947 Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Author Share Posted April 15, 2008 craygo you rock! It worked! I had forgotten about the enctype! *note to self - before proceeding add enctype Link to comment https://forums.phpfreaks.com/topic/101253-solved-upload-not-working/#findComment-517953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.