allowed file types

See all posts Reply

allowed file types new!
by Orkan, 13 years, 2 months ago
Hello,

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 ?
$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';
}


Second problem
For example if I remove allowed option png files accepted but file extension was changed to .txt ?

Thank you.Reply
Re: allowed file types new!
by Orkan, 13 years, 2 months ago
I found problem
On my local mime_content_type function return text/plain for PNG files.

This is a apache bug, here is details http://mail-archives.apache.org/mod_mbox/www-apache-bugdb/200003.mbox/%3C20000310000045.59185.qmail@locus.apache.org%3EReply