Ok so I have got the upload section working and correctly uploading and moving documents to the correct folder.
I have set the limit to 100mb and included valid file extensions. I am having issues with uploading fonts. Have I inserted the correct mime type etc.? and are they correct for the other extensions?
Also what I would like to do, is:
- When the file upload is complete (or fails), I would like to direct to a new pre-designed web page (that will fit within the design rather than have some small text on a white page). How would I put this link in to the php script? My php script at the moment is:
PHP Code:
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png", "pdf", "cdr", "ai", "eps", "indd", "tif", "tiff", "bmp", "ttf", "otf",);
$extension = end(explode(".", $_FILES["uploadedfile"]["name"]));
if ((($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "image/jpeg")
|| ($_FILES["uploadedfile"]["type"] == "image/png")
|| ($_FILES["uploadedfile"]["type"] == "application/pdf")
|| ($_FILES["uploadedfile"]["type"] == "application/cdr")
|| ($_FILES["uploadedfile"]["type"] == "application/ai")
|| ($_FILES["uploadedfile"]["type"] == "application/eps")
|| ($_FILES["uploadedfile"]["type"] == "application/indd")
|| ($_FILES["uploadedfile"]["type"] == "image/tif")
|| ($_FILES["uploadedfile"]["type"] == "image/tiff")
|| ($_FILES["uploadedfile"]["type"] == "image/bmp")
|| ($_FILES["uploadedfile"]["type"] == "font/ttf")
|| ($_FILES["uploadedfile"]["type"] == "font/otf")
|| ($_FILES["uploadedfile"]["type"] == "image/pjpeg"))
&& ($_FILES["uploadedfile"]["size"] < 104900000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["uploadedfile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["uploadedfile"]["error"] . "<br>";
}
else
{
echo "Thank you. Your file was uploaded sucessfully." ."<br>";
if (file_exists("uploads/" . $_FILES["uploadedfile"]["name"]))
{
echo $_FILES["uploadedfile"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],
"uploads/" . $_FILES["uploadedfile"]["name"]);
echo "";
}
}
}
else
{
echo "Invalid file type. Please try again or contact us for advice.";
}
?>
Bookmarks