Downloading external image

General discussions related to php

Moderators: macek, egami, gesf

Knutsford
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Mar 01, 2012 8:08 am

Downloading external image

Postby Knutsford » Wed Oct 03, 2012 6:56 am

In php how do you download an resize an external image - eg http://images.portalimages.com/large/tp ... 390021.jpg
My code is failing on


if (file_put_contents($image, file_get_contents($url))) {

and file_get_contents is returning the binary



Thanks







$url = trim($AnItem[1]);

if (file_put_contents($image, file_get_contents($url))) {
$thumb = imageToCanvas($image,100,75,true);
$medium = imageToCanvas($image,400,300,true);
$large = imageToCanvas($image,800,600,true);// 800x600
imagejpeg($thumb,$base_image_path . $thumb_path,90);
imagedestroy($thumb);
$medium_path,90);

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron