I found a free picture upload script on the webby, but it only allows JPG/JPEG formats.
How do I allow it to upload format PNG and BMP?
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = "thumbnails_".$_FILES["fileUpload"]["name"][$i];
copy($_FILES["fileUpload"]["tmp_name"][$i],"PIC_FOLDER".$_FILES["fileUpload"]["name"][$i]);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size = GetimageSize($images);
$height = round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"PIC_FOLDER".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "Resize Successful.<br>";
}
}
Thanks in advance
As the comment says you already are able to upload any type but you need it to be a jpeg to be able to make the thumbnail. Simply do a check on the type then use that to open the image
just use this instead of $images_orig = ImageCreateFromJPEG($images);
If you also want to save the images back in whatever format they came in as, do a similar check at the bottom instead of ImageJPEG($images_fin,”PIC_FOLDER”.$new_images);