Reputation: 12998
I am trying to create a simple php image uploading form. I appear to have some kind of permissions problem though and I'm not sure how to fix this...
Here's my code...
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
upload_file.php...
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Here's the error I get...
Stored in: upload/81350042.jpgPHP Warning: move_uploaded_file(upload/81350042.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\websites\tb123654\www\upload_file.php on line 27 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\upload\php5BFB.tmp' to 'upload/81350042.jpg' in D:\websites\tb123654\www\upload_file.php on line 27
Upvotes: 0
Views: 1833
Reputation: 1088
There is no folder called "uploads" in "D:\websites\tb1234\www\" so the images can't be moved there. I think that's what your script is trying to do. Try to use absolute paths and see if that works.
Upvotes: 0
Reputation: 587
open your ftp client, right click on the folder you upload things to, attributes or propieties, set permission to 777.
or
chmod 777 yourfolder
Upvotes: 2