Jump to content


Photo

uploaded file not in _FILES


  • Please log in to reply
1 reply to this topic

#1 ichijoji

ichijoji
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 October 2006 - 04:23 AM

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:
<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>
And the code that gets it on the other side is:
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>";
        }
The output that this is giving me is:
name = , tmp_name =
couldn't move file
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?

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 01 October 2006 - 07:42 AM

try this:
<form action="targetscript.php" method="post" enctype="multipart/form-data">

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users