1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get size of redirected image from remote url

Discussion in 'General PHP and MySQL Discussions' started by htdesignz, Jan 29, 2013.

  1. htdesignz

    htdesignz Active Member

    Do XF supports to get image size of redirected image from remote url?
    I have tried with Curl, but it got a empty image.

    PHP:
    $file 'http://i2.minus.com/jpWyJdpK4Kd1M.png';
     
    function 
    save_image($img$fullpath){
        
    $ch curl_init ($img);
        
    curl_setopt($chCURLOPT_HEADER0);
        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
    curl_setopt($chCURLOPT_BINARYTRANSFER,1);
        
    $rawdata=curl_exec($ch);
        
    curl_close ($ch);
        if(
    file_exists($fullpath)){
            
    unlink($fullpath);
        }
        
    $fp fopen($fullpath,'x');
        
    fwrite($fp$rawdata);
        
    fclose($fp);
    }
     
    save_image($file__DIR__ '/image.png');
     

Share This Page