Page 1 of 1
Upload image - create thumbnail - not working on MAC
Posted: Thu Aug 14, 2003 11:37 am
by tsg
I have an upload script that uploads the image and creates a thumbnail. I have one customer that is using a mac and says that the thumbnail is not being created.
Anyone now of any known issues on this with a MAC?
Thanks,
Tim
Posted: Thu Aug 14, 2003 1:10 pm
by pootergeist
most likely to be the filetype header being different to pc - if you are testing
$_FILES['field']['type']
for maybe "image/jpeg" or such then in many cases it will barf.
$arg = getimagesize($_FILES['field']['tmp_name'];
if($arg > 0 && $arg < 4)
{
// a gif / png or jpeg file
}
is a better way of testing.
we'd need to see the actual script or a var_dump($_FILES) after the mac upload to say any further.
Posted: Thu Aug 14, 2003 2:08 pm
by tsg
You must be talking about this part:
Code: Select all
<?php
if($_FILES['image']['size']){
if($_FILES['image']['type'] == "image/pjpeg"){
$im = imagecreatefromjpeg($_FILES['image']['tmp_name']);
}elseif($_FILES['image']['type'] == "image/x-png"){
$im = imagecreatefrompng($_FILES['image']['tmp_name']);
}elseif($_FILES['image']['type'] == "image/gif"){
$im = imagecreatefromgif($_FILES['image']['tmp_name']);
}
if($im){
if(file_exists("$FILENAME" . "$image_ext")){
unlink("$FILENAME" . "$image_ext");
}
ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$upload_folder . "/" . $FILENAME . $image_ext);
ImageDestroy ($im);
}
}
?>
The code might be a little messy, but is that the part you are talking about?
Posted: Thu Aug 14, 2003 5:25 pm
by tsg
Got it working .. thanks.
Posted: Fri Aug 15, 2003 5:06 am
by pootergeist
subnote: a nice (imo) approach to the conditional createfrom...? is
Code: Select all
$base_image = $_FILES['image']['tmp_name'];
$f_type = getimagesize($base_image);
$created_image = ($f_type[2] < 4)
? ($f_type[2] < 3)
? ($f_type[2] < 2)
? ($f_type[2] < 1) ?
NULL
: imagecreatefromgif($base_image)
: imagecreatefromjpeg($base_image)
: imagecreatefrompng($base_image)
: NULL;
if($created_image !== NULL)
{
// we have a created image