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">