monkeypaw201 Posted July 24, 2008 Share Posted July 24, 2008 The code is just posting to same page and nothing happens... <?php if(isset($_FILES['file'])) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "File Uploaded Successfully"; if (file_exists("../downloads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { $filename = date("siHdmY"); move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "../downloads/" . $filename; } } }else{ ?> <form method="POST" action="upload.php"> <p>Pilot ID:<br> <input type="text" name="pilot_id"> <p>File:<br> <input type="file" name="file"> <p>Title:<br> <input type="text" name="title"> <p>Description:<br> <textarea name="description"></textarea> <p>Author:<br> <input type="text" name="author"> <p><input type="submit" name="submit" value="Upload File"> </form> <?php } ?> NOTE: Its not done, but eventually it will insert Title, Author, Description, Pilot ID into database along with $filename. Link to comment https://forums.phpfreaks.com/topic/116337-solved-file-upload-help/ Share on other sites More sharing options...
monkeypaw201 Posted July 24, 2008 Author Share Posted July 24, 2008 bump Link to comment https://forums.phpfreaks.com/topic/116337-solved-file-upload-help/#findComment-598255 Share on other sites More sharing options...
monkeypaw201 Posted July 24, 2008 Author Share Posted July 24, 2008 bump again Link to comment https://forums.phpfreaks.com/topic/116337-solved-file-upload-help/#findComment-598351 Share on other sites More sharing options...
monkeypaw201 Posted July 24, 2008 Author Share Posted July 24, 2008 bump again again Link to comment https://forums.phpfreaks.com/topic/116337-solved-file-upload-help/#findComment-598720 Share on other sites More sharing options...
MFHJoe Posted July 24, 2008 Share Posted July 24, 2008 To upload a file in PHP you need enctype="multipart/form-data" in your <form> tag. Not sure if this will solve your problem but it definitely needs to be there. <form method="POST" action="upload.php" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/116337-solved-file-upload-help/#findComment-598733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.