Hi
I have a function 'checkfile'within my 'add a record'form which checks to ensure that the images which users are uploading with the form are within a certain size...in this case 32kb, which is specified within GW_MAXFILESIZE.
What would actually be much more useful and user friendly is if when the user selects an image from their desktop, the image is automatically resized to 32kb?
Does anyone know how to do this?
function checkfile($image_name,$type,$size,$tmp_name,$error)
{
$output ='start';
if (!empty($image_name))
{
if (
(($type == 'image/gif') || ($type == 'image/jpg') || ($type == 'image/pjpeg') || ($type == 'image/png') || ($type == 'image/jpeg'))
&& (($size > 0) && ($size <= GW_MAXFILESIZE))
&& ($error == '0'))
{
// Move the files to the target upload folder
$target = GW_UPLOADPATH . $image_name;
if (move_uploaded_file($tmp_name , $target) ) {$output = 'success';} else {$output = 'load error'; }
}
else { $output='error'; }
}
else { $output='success'; }
return $output;
}
This is the check which is then carried out to confirm that images are the size they are meant to be:
$image_main_check = checkfile($image_main_name,$_FILES['image_main']['type'],$_FILES['image_main']['size'],$_FILES['image_main']['tmp_name'],$_FILES['image_main']['error']) ;
If the images are too large - then a straightforward error message is displayed telling them this and to go and resize and try again....
Ideally I would like the check to happen and if the images are too large (which they probably all would be as this is a small size), then for a bit of code to automatically resize them?
This would really be the icing on the cake of this website :-)
Many thanks for any help which can be offered....