vishalkoradiya / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

mime type bug with external image curl #389

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of the product are you using? On what operating system?
2.8.10 apache
________

external image uses curl for load balance system.

http://picload.org/image/dgirwrw/1592525.jpg
redirects to http://img3.picload.org/image/dgirwrw/1592525.jpg

error log:

Starting new request from xxx.xxx.xxx.43 to 
/5.php?src=http://picload.org/image/dgirwrw/1592525.jpg&h=83
Doc root is: /home/xxx/xxxxxxx.in
Salt is: 1342479617-12087082
cleanCache() called
Cache was cleaned less than 86400 seconds ago so no cleaning needed.
Is a request for an external URL: http://picload.org/image/dgirwrw/1592525.jpg
Fetching from all external sites is enabled.
Cache file is: 
./img/cache4/timthumb_ext_c89d9dd4d93563e70ddad8abfdd53998.timthumb.txt
Trying server cache
Got request for external image. Starting serveExternalImage.
webshot is NOT set so we're going to try to fetch a regular image.
Fetching external image into temporary file 
/home/xxx/xxxxxxx.in/img/cache4/timthumbUEDhly
Scheduling file /home/xxx/xxxxxxxx.in/img/cache4/timthumbUEDhly to delete on 
destruct.
Curl is installed so using it to fetch URL.
Fetching url with curl: http://picload.org/image/dgirwrw/1592525.jpg
Remote file has invalid mime type:
Adding error message: The remote file is not a valid image.
Deleting temp file /home/xxxx/xxxxxxxxxxxx.in/img/cache4/timthumbUEDhly

I think something is wrong with the script the picload admin told me to contact 
timthumb autor.

"Remote file has invalid mime type" << this is the final error

can you reproduce and help me we use this imagehost a lot.

thanks for winderful script.

Original issue reported on code.google.com by godfatherr1988 on 16 Jul 2012 at 11:42

GoogleCodeExporter commented 8 years ago
Got that error, too. 
That was because of a 301 Redirect, which wasn't covered by the getUrl method.

I fixed it by adding this code:

if($httpStatus == 301){
    $this->getURL(curl_getinfo($curl)['redirect_url'], $tempfile);
}

in the getURL method, on line 1200 [more or less] just after 

if($httpStatus == 404){
    $this->set404();
}

Hope it helps!

Luca

Original comment by kin...@gmail.com on 19 Jun 2014 at 1:29