ichijoji Posted October 1, 2006 Share Posted October 1, 2006 Hi all,First let me say that I've been doing this php stuff for all of 5 or 6 days. I'm an experienced programmer, but web code is strange and counter-intuitive. I'm trying to upload a file onto my server and keep track of where it ends up so that I can use it as an image in a later page. The form that sends the file looks like this:[code]<form><input type="hidden" name="action" value="add_item"><tr><td>Name</td><td><input type="text" name="name"></td></tr><tr><td>Description</td><td><input type="text" name="description"></td></tr><tr><td>Price</td><td><input type="text" name="price"></td></tr><tr><td>Image</td><td><input type="file" name="imageFile"></td></tr><tr><td><input type="submit" value="add item"></td></tr></form>[/code]And the code that gets it on the other side is:[code]if ($_GET["action"] == "add_item") { echo "name = {$_FILES['imageFile']['name']}, tmp_name = {$_FILES['imageFile']['tmp_name']}<br>"; $imagePath = 'images/' . basename($_FILES['imageFile']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'],$imagePath)) { echo "moved file<br>"; } else { echo "couldn't move file<br>"; }[/code]The output that this is giving me is:[code]name = , tmp_name =couldn't move file[/code]I really don't understand what's going wrong. I've tried everything I can think of and checked about a thousand tutorials on the subject, but nothing seems to work. What am I doing wrong? Or, failing that, how can I do more error checking on the actual upload process? Quote Link to comment https://forums.phpfreaks.com/topic/22635-uploaded-file-not-in-_files/ Share on other sites More sharing options...
.josh Posted October 1, 2006 Share Posted October 1, 2006 try this:[code]<form action="targetscript.php" method="post" enctype="multipart/form-data">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22635-uploaded-file-not-in-_files/#findComment-101710 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.