Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Foto ikelimo taisymas

Parašė swz· 2014 Lap. 25 15:11:00
#1

Sveiki, turiu pasidares fotografiju kelima i tinklapi, gal kas gali padet paredaguot koda taip, kad ta foto kuri bus ikelta butu pakeista pvz visad i jpg formata ir jos dydis sumazintas iki kokiu 400 kb.


if (isset($_FILES['ascreen'])) {
         if (is_uploaded_file($_FILES['ascreen']['tmp_name'])) {
             $upload = 0;
                $data_next_ai = dbarray(dbquery("SHOW TABLE STATUS FROM ".$db_name." LIKE '".DB_NB."'"));
            $nb_id = $data_next_ai['Auto_increment'];
            $nb_screen_types = array(".gif",".jpg",".jpeg",".png");
            $nb_screen_pic = $_FILES['ascreen'];
            $file_name = $_FILES['ascreen']['name'];
            //$nb_screen_name = str_replace(" ", "_", strtolower(substr($nb_screen_pic['name'], 0, strrpos($nb_screen_pic['name'], "."))));
            $nb_screen_ext = strtolower(strrchr($nb_screen_pic['name'],"."));
            $nb_screen_dest = INFUSIONS."skelbimu_lenta/images/";
            if ($nb_screen_pic['size'] > $nb_config['size']){
                  $error = 2;
            } elseif (!in_array($nb_screen_ext, $nb_screen_types)) {
                  $error = 3;
            } else {
            require_once INCLUDES."photo_functions_include.php";
                $nb_screen_file = image_exists($nb_screen_dest, $nb_id.$file_name.$nb_screen_ext);
                move_uploaded_file($nb_screen_pic['tmp_name'], $nb_screen_dest.$nb_id.$file_name.$nb_screen_ext);
                chmod($nb_screen_dest.$nb_screen_file, 0644);
                $imagefile = @getimagesize($nb_screen_dest.$nb_screen_file);
                if ($imagefile[0] > $nb_config['width'] || $imagefile[1] > $nb_config['height']) {
                  $error = 4;
                  unlink($nb_screen_dest.$nb_id.$file_name.$nb_screen_ext);
               } else {
                          $ascreen = $nb_id.$file_name.$nb_screen_ext;
                  $upload = 1;
               }
            }
         }
      }