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? Quote Link to comment Share on other sites More sharing options...
craygo Posted April 15, 2008 Share Posted April 15, 2008 Any errors?? Quote Link to comment 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... Quote Link to comment 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?? Quote Link to comment 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 Quote Link to comment 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'>"; Quote Link to comment 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 Quote Link to comment 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 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.