I’m using the FileReference class with PHP to allow users to upload images. I need to be able to restrict the size (pixels not bytes) of the images.
Currently, I have the following PHP script which handles the uploads and checks the width and height of the image before copying it to the server:
<?php
if ($_FILES['Filedata']['name']) {
list($width, $height, $type, $attr) = getimagesize($_FILES['Filedata']['tmp_name']);
if($width <= 15 && $height <= 15) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], 'uploadedImages/' . basename($_FILES['Filedata']['name']));
}
}
?>
This works ok, but it does not provide a method to alert Flash if the image is bigger than the allowed values. It simply doesn’t copy the file.
So, is there a way to call the onCancel event for the FileReference object from PHP? Or is there any other way I could alert flash of the status from that PHP file?
Even better than that - is there a way to determine the image size before it is uploaded? The PHP script above still has to wait for the temp image to be uploaded before it can perform the validation.
Cheers.