Reputation: 43
Editted
Now I am encountered another problem which is upload file is not saving into upload folder I set up.
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.";
?>
Upvotes: 4
Views: 7113
Reputation: 41737
<?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:
Upvotes: 4
Reputation: 46
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.
Upvotes: 3