Re: Non0image files always get an additional extension of .txt

See all posts Reply

Re: Non0image files always get an additional extension of .txt new!
by Ken Moore, 10 years, 8 months ago
I've a fairly normal file upload process...

$handle = new Upload($_FILES['filename']);
if ($handle->uploaded) {
  $handle->image_resize            = true;
  $handle->image_x                 = 800;
  $handle->image_y                 = 600;
  $handle->image_ratio             = true;
  $handle->file_safe_name          = true;
  $handle->file_overwrite          = true;
  $handle->Process($dir);
  if (!$handle->processed) {	// error
    echo "Error 1: $handler->error";
    $OK = false;
  }
}

Uploads work fine and images do exactly what I want but non-images files have the extension .txt added, for example, docs.pdf uploads as docs.pdf.txt.

So what am I doing wrong? Is it simply that my logic is expecting to process and resize images and so, not being an image, it gets the extension added? Do I need to check for image uploads ($file_is_image) and use different logic for non-images?Reply
Re: Non0image files always get an additional extension of .txt new!
by colin, 10 years, 8 months ago
Check the log produced by the class. The txt extension is added if the file is thought to be dangerous. Check the MIME types detection on your server, and see in the logs why you get the txt extension added.

You can also use file_is_image to process your file differently if it is not an image.Reply