[php]
$file = $_FILES[“file”];
function isAllowedExtension($fileName)
{
if (endsWith($fileName,".txt") || endsWith($fileName,".doc") || endsWith($fileName,".rtf") || endsWith($fileName,".docx"))
{
return true;
}
else
{
return false;
}
}
function endsWith($string, $endsWith)
{
$length = strlen($endsWith);
if ($length == 0)
{
return true;
}
$start = $length * -1;
return (substr($string, $start) === $endsWith);
}
if ((isAllowedExtension($file[“name”])) || ($file[“type”] == “image/*”)) && ($file[“size”] < 1048576)
{
if ($file[“error”] > 0)
{
die(“Error: " . $file[“error”] . “
”);
}
else
{
if (file_exists(“errorMSG/” . $file[“name”]))
{
die($file[“name”] . " already exists. Try renaming it.”);
}
else
{
move_uploaded_file($file[“tmp_name”], “errorMSG/” . $file[“name”]);
echo “Upload Successful!\n\nThank You for the Screenshot!”;
}
}
}
else
{
die(“Invalid file, files MUST be an image and under 600kb.”);
}
[/php]
What it Prints:
0) { die("Error: " . $file[“error”] . "
“); } else { if (file_exists(“errorMSG/” . $file[“name”])) { die($file[“name”] . " already exists. Try renaming it.”); } else { move_uploaded_file($file[“tmp_name”], “errorMSG/” . $file[“name”]); echo “Upload Successful!\n\nThank You for the Screenshot!”; } } } else { die(“Invalid file, files MUST be an image and under 600kb.”); } ?>