/    Sign up×
Community /Pin to ProfileBookmark

Hi

I’m creating images dynamically using php (GD library) which displays the image just fine on the page, but I want to be able to save the image (with a dynamically derived name) in a higher directory.

Any know how to do this. Attempts using file_copy_contents and the like don’t seem to be working – I wonder if I need some kind of binary copying thing or other. I’m pleading ignorance.

Any help appreciated

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ZnupiMar 26.2007 — So far you are probably using imageGif() or imagePng() or imageJpg() or whatever to output your images, right? Well, just pass as a second argument the filename to save the image to...
[code=php]
$img = imageCreate($width, $height);
// Do whatever you wish to the image...
$fileName = "/images/dynamic/image.gif";
imageGif($img, $fileName);
[/code]

This way, $img will be saved to /images/dynamic/image.gif. ?
Copy linkTweet thisAlerts:
@zingmatterauthorMar 26.2007 — Spot on! Thanks.
×

Success!

Help @zingmatter 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...