Extension as TXT

See all posts Reply

Extension as TXT new!
by Jefferson, 11 years, 1 month ago
Hi guys, i have this issue, even with $handler->image_convert = 'jpg';, the image comes with txt extension. Here is my code:

include('../../../config.php');
$id = strip_tags( $_GET['id'] );
require_once 'Upload.php';
if(isset($_POST['sendFiles'])){
  if(isset($_FILES['file']) and ($_FILES['file']['tmp_name'] != "")){
    foreach($_FILES['file']['tmp_name'] as $key => $value){
      $upload = new Upload($value);
      if($upload->uploaded){
        $upload->file_new_name_body = "sind";
        $upload->file_dst_name = strtolower($_FILES);
        $upload->image_resize = true;
        $upload->image_ratio_y = true;
        $upload->image_x = 768;
        $upload->image_convert = 'jpg';
        $upload->jpeg_quality = 80;
        $upload->process('../imagens/upload/');
        if($upload->processed){
          $fotos = $upload->file_dst_name;
          $sql = mysql_query("INSERT INTO fotos_galerias (id_galeria, foto, obs_foto) VALUES ('$id', '$fotos', '$desc_')") or print(mysql_error());
        } else {
          echo $upload->error;
        }
      }
    }
  }
}
Reply
Re: Extension as TXT new!
by colin, 11 years, 1 month ago
Paste here the log produced by the class. It is probably a MIME type detection issue.Reply
Re: Extension as TXT new!
by Jefferson, 11 years, 1 month ago
I couldn't get the log. I've tried to use different dir's (../images/upload, /srv/www/domain.com/images/upload), tryied to set as "false" mime_magick, mime_check, nothing helped.Reply
Re: Extension as TXT new!
by Jefferson, 11 years, 1 month ago
Well, solve by changing from $file_src_name_ext = 'txt'; to $file_src_name_ext = 'jpg';Reply
Re: Extension as TXT new!
by ciko, 8 years, 10 months ago
I'm having the same problem

Only work if i change:

if ((((substr($this->file_src_mime, 0, 5) == 'text/' && $this->file_src_mime != 'text/rtf') || strpos($this->file_src_mime, 'javascript') !== false) && (substr($file_src_name, -4) != '.txt'))

to:

if ((((substr($this->file_src_mime, 0, 5) == 'text/' && $this->file_src_mime != 'text/rtf') || strpos($this->file_src_mime, 'javascript') !== false) && (substr($file_src_name, -4) != '.jpg'))Reply