/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Image Downloading

is it possible to download a image from one server to another in php, maybe using GD functions i cant seem to figure anything out, ive looked through the PHP manual but cant see anything. If anyone has any code examples or tips

Example

[code=php]
$img = “http://blah/img1.jpg”;
$new_location = “http://fish/img24.jpg”;
[/code]

Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@gavshouseauthorJan 15.2009 — [code=php]<?php
function LoadPNG($imgname)
{
/* Attempt to open */
$im = @imagecreatefrompng($imgname);

/* See if it failed */
if(!$im)
{
/* Create a blank image */
$im = imagecreatetruecolor(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 150, 30, $bgc);

/* Output an error message */
imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}

return $im;
}

header('Content-Type: image/png');

$img = LoadPNG('http://blah/img1.jpg');

imagepng($img);
imagedestroy($img);
?>[/code]


This seems to load the image into the browser but how can i save this ?, this function says it will but i cant seem to get it working http://uk2.php.net/manual/en/function.imagepng.php
×

Success!

Help @gavshouse spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...