AFTER I USE UPLOAD SCRIPT, CAN'T VIEW IMAGE "FORBIDDEN"
Posted: Fri Jun 06, 2008 8:39 pm
I created a file upload script for a web project that I am working on. It works wonderfully...you upload the file and it appears on the server.
BUT...when you go to view it...say using "http://www.mysite.com/uploads/image.jpg"...it says "forbidden" access denied and so on. This must have something to do with the fact that the image was uploaded using my script since images uploaded using the FTP can be viewed no problem.
Any ideas on what could be causing this problem? Thanks!
My image upload script looks like this:
Then my simple html to view the image is:
<img src="uploads/image.jpg">
BUT...when you go to view it...say using "http://www.mysite.com/uploads/image.jpg"...it says "forbidden" access denied and so on. This must have something to do with the fact that the image was uploaded using my script since images uploaded using the FTP can be viewed no problem.
Any ideas on what could be causing this problem? Thanks!
My image upload script looks like this:
Code: Select all
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] <= 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
//Upload file
$ext = explode("/", $_FILES["file"]["type"]);
if ($ext[0] == "image") {
move_uploaded_file($_FILES["file"]["tmp_name"],
"fileUploads/" . $_FILES["file"]["name"]);
}
}
}
}
else
{
echo $_FILES["file"]["type"] . " " . $_FILES["file"]["size"] . "<br>";
echo "Invalid file";
}
?><img src="uploads/image.jpg">