Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/22635-uploaded-file-not-in-_files/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.