1. mime types. I am trying to only allow jpegs be uploaded. However, there seem to be more than one (3) mime types for jpegs. I want to know what they are and how to add them in.
2. Size. I would like to restrict the size of the file to be <150k. I see that there is a size variable in this script. However, i dont' know where to insert the test of size.
also, is this the best way to handle file uploads?
Code: Select all
if (!empty($_FILES['Menu_pict']['name'])) {
if ($_FILES['Menu_pict']['type'] == "image/jpeg")
{
copy ($_FILES['Menu_pict']['tmp_name'], "../images/food/".$_FILES['Menu_pict']['name'])
or die ("Could not copy");
echo "<B>Name:</B> ".$_FILES['Menu_pict']['name']." ";
echo "<B>Size:</B> ".$_FILES['Menu_pict']['size']." ";
echo "<B>Type:</B> ".$_FILES['Menu_pict']['type']." ";
echo "<FONT COLOR="CC0000">Copy Done....</FONT>";
}
else
{
echo "<br><br>";
echo "Could Not Copy, Wrong Filetype (".$_FILES['Menu_pict']['name'].")<br>";
echo ($_FILES['Menu_pict']['name']) ."<BR>";
}
}
// End File Upload