Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


PHP - can you upload an animated GIF?

Posted on 2009-04-20
Medium Priority
Last Modified: 2012-05-06
I use the following code to upload images and would like to know if it can be modified to upload an animated gif.
Currently when I try to upload an animated gif the uploaded file beomes a static gif.
Thanks in advance for your feedback.
$image = imagecreatefromgif($tempFile);
//Get width & height of uploaded image.
$imWidth = imagesx($image);
$imHeight = imagesy($image);

if (($imWidth > $maxiw) || ($imHeight >  $maxih)){
$s = min($maxiw/$imWidth , $maxih/$imHeight);
$liWidth= round($s * $imWidth);
$liHeight= round($s * $imHeight);
}else {
$liWidth =  $imWidth;
$liHeight = $imHeight;

//Create Large Image
$largepic = imagecreatetruecolor($liWidth ,$liHeight);
imagecopyresampled($largepic, $image, 0, 0, 0, 0, $liWidth, $liHeight, $imWidth, $imHeight);
Question by:sabecs
LVL 17

Accepted Solution

Chris Harte earned 2000 total points
ID: 24189079
Apparently this is not as straight forward as it sounds. Gifs are still a proprietary format so support is patchy. However, this is something I have not tried.


Author Closing Comment

ID: 31572232
Thanks for your feedback.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question