I am using the following code for user to upload an image.
if ((($_FILES["companylogofile"]["type"] == "image/jpeg")
|| ($_FILES["companylogofile"]["type"] == "image/pjpeg"))
&& ($_FILES["companylogofile"]["size"] < 75000))
{
if ($_FILES["companylogofile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["companylogofile"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["companylogofile"]["name"] . "<br />";
echo "Type: " . $_FILES["companylogofile"]["type"] . "<br />";
echo "Size: " . ($_FILES["companylogofile"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["companylogofile"]["tmp_name"] . "<br />";
if (file_exists("Template/" . $_FILES["companylogofile"]["name"]))
{
echo $_FILES["companylogofile"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["companylogofile"]["tmp_name"],
"Template/" . $_FILES["companylogofile"]["name"]);
}
}
}
else
{
echo "Invalid file";
}
As you can see I only accept .jpeg files to be upload with a restriction on size. What I also need to do is add a restriction to the name of the file they are upload. Basically I want to only allow files to be uploaded if they are named say: Logo. Is there a way to put a restriction on the name of the files being uploaded?
Thanks!