php - problems on file upload breaking GIF images -


hello have added simple image resize breaking gif animations. me decipher here needs removed existing code allow image uploaded , animated in gif form...thank input.

 case 'addgift':             if($adminlevel == 4)             {                 if ($_files['uploadedfile']['tmp_name'] != "")                 {                     $image = new simpleimage();                     $image->load($_files['uploadedfile']['tmp_name']);                     $width = $image->getwidth();                     $height = $image->getheight();                     if($width > 64) {                        $height = (64/$width)*$height;                        $width = 64;                     }                     if($height > 64) {                        $width = (64/$height)*$width;                        $height = 64;                     }                     $image->resize($width,$height);                     if(preg_match("/\.(png)$/i", $_files['uploadedfile']['name']))                         $type = imagetype_png;                     else if(preg_match("/\.(gif)$/i", $_files['uploadedfile']['name']))                         $type = imagetype_gif;                     else                         $type = imagetype_jpeg;                     $image->save("images/gifts/".$_files['uploadedfile']['name'], $type);                     unlink($_files['uploadedfile']['tmp_name']);                      mysql_query("insert gifts                                 (name, image, cash, tokens)                                 values ('".mysql_real_escape_string($_post['name'])."', '".$_files['uploadedfile']['name']."', ".intval($_post['cash']).", ".intval($_post['tokens']).")");                     mysql_query("insert admin_actions                                 (id1, id2, action, extra, time)                                 values($userid, 0, '{id1} added gift \"{extra}\".', '".mysql_real_escape_string($_post['name'])."', unix_timestamp())");                 }             }             break; 

i don't know if lib supports such thing. can check image meets size limit , keep untouched in case does.

- $image->resize($width,$height); - $image->save("images/gifts/".$_files['uploadedfile']['name'], $type); - unlink($_files['uploadedfile']['tmp_name']);  + if ($image->getwidth() == $width && $image->getheight() == $height) +     move_uploaded_file($_files['uploadedfile']['tmp_name'], "images/gifts/".$_files['uploadedfile']['name']); + else + { +     $image->resize($width,$height); +     $image->save("images/gifts/".$_files['uploadedfile']['name'], $type); +     unlink($_files['uploadedfile']['tmp_name']); + } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -