Jump to content


This topic is now archived and is closed to further replies.


uploaded file not in _FILES

Recommended Posts

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?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.