Welcome Guest, Not a member yet? Register   Sign In
Upload From URL
#2

[eluser]xwero[/eluser]
You could put it in a custom library and load it when necessary.

I adjusted and tested a working function from php.net code snippets.
Code:
class Image_util
{
   function img_from_url($imgurl,$downloaddir='',$quality=85)
   {
    $file = substr(strrchr($imgurl,'/'),1);
    $filename = substr($file,0,strrpos($file,'.'));
    $ext = strtolower(substr(strrchr($file,'.'),1));
    if ($ext == 'jpg' || $ext == 'jpeg')
    {
      $img = @imagecreatefromjpeg($imgurl);
    }
    else if ($ext == 'png')
    {
      $img = @imagecreatefrompng($imgurl);
    }
    else if ($ext == 'gif')
    {
      $img = @imagecreatefromgif($imgurl);
    }
    // If an image was successfully loaded, test the image for size
    if ($img)
    {
       imagejpeg($img,$downloaddir.$filename.'.jpg',$quality);
    }
  }
}


Messages In This Thread
Upload From URL - by El Forum - 10-23-2007, 09:24 AM
Upload From URL - by El Forum - 10-23-2007, 02:01 PM
Upload From URL - by El Forum - 10-23-2007, 02:03 PM
Upload From URL - by El Forum - 10-23-2007, 10:52 PM
Upload From URL - by El Forum - 10-24-2007, 12:08 AM
Upload From URL - by El Forum - 10-24-2007, 01:11 AM
Upload From URL - by El Forum - 10-24-2007, 01:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB