0

I know there's questions on this issue but I'm trying to get images uploaded to a directory using move_uploaded_file. I'm using the example from the php manual http://www.php.net/manual/en/function.move-uploaded-file.php but I'm getting an Undefined index: file. File is the name of my file input type so I'm not sure why it's undefined.

Here is my form:

<form action="MoveImages.php" class="dropzone" id="my-awesome-dropzone" method="post">
        <input type="file" name="file" />
        <input TYPE="submit" name="upload" title="Add Images" value="Add Photo"/>
</form>

Here's my PHP file:

<?php
$uploads_dir = '/Users/Jane/Desktop/NE';
$tmp_name = $_FILES["file"]["tmp_name"];
$name = $_FILES["file"]["name"];
move_uploaded_file($tmp_name, "$uploads_dir/$name");

?>

Can anyone see where I am going wrong?

1 Answer 1

3

Add enctype="multipart/form-data" in your form tag. That attribute is required when you are uploading file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.