I've been trying for a few days to get file size and file type restrictions to work with the following Swift code:
Code: Select all
//Check if an attachment was uploaded
$file_path = false;
$file_name = false;
$file_type = false;
if (!empty($_FILES["attachment"]["tmp_name"]))
{
if ($_FILES["attachment"]["error"])
{
//Redirect if the upload has failed
header("Location: ./form.php?error=upload_failed");
exit();
}
$file_path = $_FILES["attachment"]["tmp_name"];
$file_name = $_FILES["attachment"]["name"];
$file_type = $_FILES["attachment"]["type"];
}
//Everything looks ok, we can start Swift
Code: Select all
if (($_FILES["attachment"]["type"] == "image/gif")
|| ($_FILES["attachment"]["type"] == "image/jpeg")
|| ($_FILES["attachment"]["type"] == "image/png" )
&& ($_FILES["attachment"]["size"] < 10000))http://www.swiftmailer.org/wikidocs/v3/ ... /form2mail
I'm not very proficient with PHP and it would be great if anyone has better ideas of how to accomplish this. Any help would be greatly appreciated.
Thanks!
Kevin