I am using this function to upload my files:
if ((($_FILES["Artwork"]["type"] == "image/gif")
|| ($_FILES["Artwork"]["type"] == "image/jpeg")
|| ($_FILES["Artwork"]["type"] == "image/jpg")
|| ($_FILES["Artwork"]["type"] == "image/pjpeg"))
&& ($_FILES["Artwork"]["size"] < 20000000))
{
if ($_FILES["Artwork"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";
}else{
$imageName = $_FILES['Artwork']['name'];
move_uploaded_file($_FILES["Artwork"]["tmp_name"],
$path_image . $imageName);
}
}else{
//echo "invalid file";
}
How do I change $imageName = $_FILES['Artwork']['name']; with a custom name, but mantaining the file extension in the name, so for example: myCustomName.jpg?
Thanks!
['type']field. That's user-provided data and is trivial to forge. use something server-side, such as FileInfo, to get a mime-type. Still not 100%, but much better than the 0% reliability of the['type']field.