Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
upload images webp
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Support

2020-11-04 12:10:02
Hello
I would like to be able to upload an image with the webp extension.
here are my changes made:

config.php
$site_config['allowed_image_types'] = array(
                   // "mimetype" => ".ext",
                   "image/gif" => ".gif",
                   "image/pjpeg" => ".jpg",
                   "image/jpeg" => ".jpg",
                   "image/jpg" => ".jpg",
                   "image/png" => ".png",
                   "image/webp" => ".webp"
               );


fonctions.php
    // [img=http://www/image.gif] taille img shout
     $s = preg_replace("/\[img1=((https):\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg|\.webp))\]/i", "<img class='img1-shout' border='0' src=\"\\1\" width=\"100\" alt='&#9888; Auncune Pochette ! &#9904;' />", $s);    


     // by spiritblue
     $s = preg_replace("/\[img\]((https):\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg|\.webp))\[\/img\]/i", "<img border=\"0\" src=\"\\1\" alt=\"\" onload=\"NcodeImageResizer.createOn(this);\">", $s);

   // [imgsmall]http://www/image.gif[/img]
   $s = preg_replace("/\[imgsmall\]((https):\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg|\.webp))\[\/img\]/i", "<img border=\"0\" src=\"\\1\" height=\"150px\" alt=\"\" onload=\"NcodeImageResizer.createOn(this);\">", $s);

   // [img=http://www/image.gif]
   $s = preg_replace("/\[img=((https):\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg|\.webp))\]/i", "<img border=\"0\" src=\"\\1\" alt=\"\" onload=\"NcodeImageResizer.createOn(this);\">", $s);


torrents-uploads.php

    //upload images
   $allowed_types = &$site_config["allowed_image_types"];
   $inames = array();
   for ($x=0; $x < 2; $x++) {
       if (!($_FILES[image.$x]['name'] == "")) {
           $y = $x + 1;
           if (!preg_match('/^(.+)\.(jpg|gif|png|webp)$/si', $_FILES[image.$x]['name']))
           show_error_msg(T_("INVAILD_IMAGE"), T_("THIS_FILETYPE_NOT_IMAGE"), 1);
           if ($_FILES['image$x']['size'] > $site_config['image_max_filesize'])
               show_error_msg(T_("ERROR"), T_("INVAILD_FILE_SIZE_IMAGE"), 1);
           $uploaddir = $site_config["torrent_dir"]."/images/";
           $ifile = $_FILES[image.$x]['tmp_name'];
           $im = getimagesize($ifile);
           if (!$im[2])
               show_error_msg(T_("ERROR"), sprintf(T_("INVALID_IMAGE"), $y), 1);
           if (!array_key_exists($im['mime'], $allowed_types))
               show_error_msg(T_("ERROR"), T_("INVALID_FILETYPE_IMAGE"), 1);
           $ret = SQL_Query_exec("SHOW TABLE STATUS LIKE 'torrents'");
           $row = mysql_fetch_array($ret);
           $next_id = $row['Auto_increment'];
           $ifilename = $next_id . $x . $allowed_types[$im['mime']];
           $copy = copy($ifile, $uploaddir.$ifilename);
           //if (!$copy)
           //    show_error_msg(T_("ERROR"), sprintf(T_("IMAGE_UPLOAD_FAILED"), $y), 1);
           $inames[] = $ifilename;
       }}
   //end upload images


Erreur: Invalid image 1

Have any idea of the problem !?
Thanks
2021-02-12 09:48:04
up ^^
2021-02-12 14:36:57
my torrents-upload has a few lines commented out. I dont remember why, but im sure it was for a reason, but I havent tried webp images. I may try it later and see


//if (!preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[image.$x]['name']))
// show_error_msg(T_("INVAILD_IMAGE"), T_("THIS_FILETYPE_NOT_IMAGE"), 1);

 
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-02-12 14:37:50
2021-02-14 05:29:23
Hello and thank you ,
I believe that it is on the server side that you need to add, or activate a php extension !?
What do you think ?
2022-04-18 14:19:38
allo
après upload mon erreur si dessous n’appairent pas ?

    // Warning upload image1 		
       if (($num = $_FILES['image0']['error']))
autolink("torrents-upload.php", T_("ERROR_UPLOAD_IMAGE1"));
                    //$message = T_("ERROR_UPLOAD_IMAGE1");
   // End


Merci de votre aide.
Last edited by spiritblue on 2022-04-18 14:19:57
2022-04-19 16:07:01
had a quick look at this - webp works fine - it makes image files smaller so I will make a function  to convert png, jpeg etc to webp - so thank you

now for the problem - gd is default in php 8 but for older you need to install gd extension   👍

Update
Just noticed first post is old but still useful  😀
Last edited by M-jay warn on 2022-04-19 16:30:22
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728