4

Editted

Now I am encountered another problem which is upload file is not saving into upload folder I set up.

Below are resolved

I have been working with this simple HTML and PHP code to upload files into web server but this error is keep displaying every time I tried to upload file into the server. File is not uploaded into server.

I am using Windows 7, IIS 7.5, PHP 5.6.2

I have already created folder for uploaded files (uploads) and I have given full control permission to all of my web server folders to IIS user.

I tried to search on the web first but I could not notice any similar problems as mine.

Here is detailed error message

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Here is my HTML script

<!DOCTYPE html>    
    <body>
        <form action="upload.php" 
              method="post" 
              enctype="multipart/form-data">
            <label for="file">
                Filename:
            </label>
            <input type="file" 
                   name="file" 
                   id="file"><br />
            <input type="submit" 
                   value="submit">
        </form>
    </body>
</html>

Here is my PHP script

<?php
    $my_folder = "uploads/";
    copy($_FILES["file"]["tmp_name"],$my_folder.$_FILES["file"]["name"]);
    echo "File uploaded.";
?>
5
  • IIS will throw 404 for any attempt to access a file extension it doesn't recognize, even if the file exists. You probably didn't configure PHP properly in your server. Commented Oct 21, 2014 at 19:31
  • just fixed 404 error but now I m encountering uploaded file not stored in the folder I set up Commented Oct 21, 2014 at 19:32
  • please post the directory strucutre of your project and a snapshot of the console of your browser about the network activities. Also, indicate where is the http root of your project Commented Oct 21, 2014 at 19:33
  • instead of copy, use the move_uploaded_file function. php.net/manual/pt_BR/function.move-uploaded-file.php Commented Oct 21, 2014 at 19:34
  • I switched to move_uploaded_file function, now I am having HTTP 500 internal server error... :( Commented Oct 21, 2014 at 19:42

2 Answers 2

4
<?php

$my_folder = "./uploads/";

if (move_uploaded_file($_FILES['file']['tmp_name'], $my_folder . $_FILES['file']['name'])) {
    echo 'Received file' . $_FILES['file']['name'] . ' with size ' . $_FILES['file']['size'];
} else {
    echo 'Upload failed!';

    var_dump($_FILES['file']['error']);
}

Check for read/write permissions on the target folder.

PHP Manual:

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

10 Comments

its not working either... I gave full control to everyone but its not working
it echo "upload filed!"
And whats the file upload error your get? var_dump($_FILES['file']['error']);
Upload failed!int(6) this is whats showing on the browser
"UPLOAD_ERR_NO_TMP_DIR" Missing temporary dir - php.net/manual/de/features.file-upload.errors.php Have you properly configured your temporary path in php.ini's file uploads section: set the "upload_tmp_dir" directive?
|
3

I had the same problem, i tried everything for 2 hours and finally I figured out that Read/Write permissions on the folder is the trick.

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.