Problem with upload PNG images

See all posts Reply

Problem with upload PNG images new!
by Alvaro, 13 years, 5 months ago
hi, i have a strange problem when i try to upload png images only, the image is not uploaded and on my database i get this /tmp/phpoOkg67

this problem a server configuration but my support dont help yet - somebody know anything?

$handle = new Upload($_FILES["Webradio_Rodape"]);  
if ($handle->uploaded){     
  $imageName = $handle->file_src_name;
  $handle->file_new_name_body   = date("Ymdhis").md5($imageName);
  $handle->mime_check           = true;   
  $handle->allowed              = array('image/*');
  //$handle->image_convert      = '';
  if(($handle->image_src_x > 200) || ($handle->image_src_y > 100)){
    $handle->image_resize     = true;
    $handle->image_ratio      = true;
    $handle->image_x        = 200;
    $handle->image_y        = 100;      
  }
  $handle->Process('../img/Webradio/');
  if ($handle->processed){
    $Webradio_Rodape = $handle->file_dst_name;
  }
}
Reply
Re: Problem with upload PNG images new!
by colin, 13 years, 5 months ago
Can you copy here the log produced by the class? The log will explain it all.

I don't think there is a bug in the class, but more likely a problem with MIME
detection libraries installed on your system.Reply
Re: Problem with upload PNG images new!
by sakiss, 13 years, 5 months ago
Hi

I am having the same problem in my application.
Your help is really appreciated.

This is my log:

- class version : 0.30
- operating system : Linux
- PHP version : 5.2.17
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 50M (52428800 bytes)
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
UNIX file() command failed
- Checking MIME type with mime.magic file (mime_content_type())
MIME type detected as text/plain by mime_content_type()
- MIME validated as text/plain
source variables
- You can use all these before calling process()
file_src_name : child.png
file_src_name_body : child
file_src_name_ext : png
file_src_pathname : /tmp/phpVxcgAL
file_src_mime : text/plain
file_src_size : 36177 (max= 52428800)
file_src_error : 0Reply
Re: Problem with upload PNG images new!
by colin, 13 years, 5 months ago
Your system's MIME detection tools are out of date or badly set up. mime_content_type should not return text/plain for an image.

If it is buggy, you can deactivate mime_content_type by setting mime_magic to false in the init() function:
$this->mime_magic               = false;
Reply
Re: Problem with upload PNG images new!
by sakiss, 13 years, 4 months ago
Hi

Thanks for the prompt reply.

I have 2 quetsions:

1) Could this aggect other functions such as the resize and convert?
2) Where should i set $this->mime_magic= false;

If i do that there will be no control to the file types that will be uploaded?Reply
Re: Problem with upload PNG images new!
by colin, 13 years, 4 months ago
1. No, this just deals with MIME detection. If the file is accepted, and is an image, then all image-related functions will work.

2. In the code, inside the init() function, line 2206 in version 0.31.

3. Other MIME type detection methods are available if your system supports them. Check the log produced by the class to see how are the files detected.Reply