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!
The only line you need modified in your code is:
Where ‘CustomName.’ is the new name you want for the image.
pathinfo if the PHP function to handle the operations with paths and files names.
You whole code would be: