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.
more info about the class
$handle = new Upload($_FILES['fileData']); if ($handle->uploaded) { $handle->image_resize = false; $handle->auto_create_dir = true; $handle->file_auto_rename = true; $handle->file_safe_name = true; $handle->file_max_size = $sql['img_upload_limit']; $handle->allowed = array('image/jpeg','image/jpg','image/gif','image/png','image/bmp'); $handle->file_new_name_body = uniqid($prefix).'_'.md5(microtime()).'_'.time(); $handle->process($targetPath); if ($handle->processed) { $return = '/' . UP . '/media/' . $handle->file_dst_name; } echo $return; } else { echo 'false'; }
When I set allowed file types like below, PNG files does not accept.
I have tried to test different png files but always rejected by class.
I can't find solution for png files, can anyone tell me why allowed option not working for png files ?
Second problem
For example if I remove allowed option png files accepted but file extension was changed to .txt ?
Thank you.