class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Hi, Colin! Now I try to execute the following algorithm: 1) the maximum size of a file is 300 kilobytes 2) the maximum sizes of a file is 1024*768 pixels If the user has prepared in advance a file according to these rules, recalculation should not be made. And at me on an input volume of a file of 290 kilobyte, after upload I have 150 kilobytes. How it is possible to avoid recalculation?
Second question. How I can forbid to upload the files which are distinct from JPEG? For example, if the user takes in head to upload GIF, and I do not want it? Whether it is possible to include $handle-> image_convert = ' jpg '; whether it will influence loading JPEG-files?
It is currently not possible to avoid calculation if the uploaded image has already the dimensions that you want to resize it to.
However, the class provides some information about the image, before calling process(). Available are image_src_x, image_src_y and the newly introduced image_src_bits, image_src_pixels and image_src_type. Using these, you can process the picture differently.
For your second question, if you use $handle->image_convert = ' jpg ';, then all images will be converted to JPEG. If you want to restrict to JPEG only, use:
Hi, Colin! Thanks. I spent tests and could not find essential distinctions between jpeg 300 kilobytes and Jpeg 150 kilobytes. Probably, I shall leave all on the places.Reply
I try to use $handle->allowed = array('image/jpg','image/jpeg');, but have error with processing JPEG: unsupported file type.... SAD. Changing to 'image/*' -- have not errors.Reply
Now I try to execute the following algorithm:
1) the maximum size of a file is 300 kilobytes
2) the maximum sizes of a file is 1024*768 pixels
If the user has prepared in advance a file according to these rules, recalculation should not be made. And at me on an input volume of a file of 290 kilobyte, after upload I have 150 kilobytes. How it is possible to avoid recalculation?
Second question.
How I can forbid to upload the files which are distinct from JPEG? For example, if the user takes in head to upload GIF, and I do not want it? Whether it is possible to include $handle-> image_convert = ' jpg '; whether it will influence loading JPEG-files?
Thanks a lot. Regards
However, the class provides some information about the image, before calling process(). Available are image_src_x, image_src_y and the newly introduced image_src_bits, image_src_pixels and image_src_type. Using these, you can process the picture differently.
For your second question, if you use $handle->image_convert = ' jpg ';, then all images will be converted to JPEG.
If you want to restrict to JPEG only, use:
I spent tests and could not find essential distinctions between jpeg 300 kilobytes and Jpeg 150 kilobytes. Probably, I shall leave all on the places.
Now I have construct that code:
I try to use $handle->allowed = array('image/jpg','image/jpeg');, but have error with processing JPEG: unsupported file type.... SAD. Changing to 'image/*' -- have not errors.