peteyb383
03-02-2008, 11:31 PM
Hi,
I recently started hosting my own website on my computer, instead of a third party hosting site. I set up the databases, included PHP and everything was running fine under IIS 7 on Vista. However, I have a file upload script that no longer works on my site. the code stayed the same from the other hosting service and on my computer. So I am basically asking whether there a setting or something that needs to be changed in order to allow file upload. In my fileupload.php code, it returns "Invalid File" when the criteria for the image is not met, and every time I try to upload a file in the criteria, I receive that error.
Here is my code:
<form accept-charset="UNKNOWN" action="fileupload.php" method="post" enctype="multipart/form-data">
<label for="file">Picture Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
fileupload.php:
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 850000))
{
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("uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
I recently started hosting my own website on my computer, instead of a third party hosting site. I set up the databases, included PHP and everything was running fine under IIS 7 on Vista. However, I have a file upload script that no longer works on my site. the code stayed the same from the other hosting service and on my computer. So I am basically asking whether there a setting or something that needs to be changed in order to allow file upload. In my fileupload.php code, it returns "Invalid File" when the criteria for the image is not met, and every time I try to upload a file in the criteria, I receive that error.
Here is my code:
<form accept-charset="UNKNOWN" action="fileupload.php" method="post" enctype="multipart/form-data">
<label for="file">Picture Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
fileupload.php:
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 850000))
{
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("uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}