Jump to content

Recommended Posts

I'm pretty new to PHP in general, and at the moment I'm working with the code snippet below trying to answer what should be a simple question:

When the "inputtext" variable exists, passing the var to the GD imagestring function, the imagepng($im) outputs the combined text on the image.......but what keeps it from being accessible by "right-click/Save picture"?

I'm having difficulty figuring out the right question to ask of he documentation, and while I'm thinking that the simplest soluton will involve output buffering, I haven't been able to get an understanding of the topic enough to see how it would be applied here......

Any pointers in the right direction would be ever so much appreciated.....

Example I'm workin with:
[code]<?php
if($_POST['inputtext']){
$im = imagecreate(80, 30);
$bg = imagecolorallocate($im, 255, 245, 134);
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 0, 0, $_POST['inputtext'], $textcolor);
header("Content-type: image/png");
imagepng($im);
} else {
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
Text: <input name="inputtext" value="" type="text" /><br />
<input type="submit" name="submit" value="Click Me" />
</form>
<?php
}
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/12121-php-gd-ifthen-behavior/
Share on other sites

OK, here goes:

Goal: Have form that asks for text, then submits that text to a GD imagestring, putting the submitted text into/on the graphic.

What's done so far: Put the form and the GD function into a single script. Started by having the GD script in a separate .php file and callin the image with a <IMG tag, but after messing with magic quotes/addslashes (to handle when I submitted non-text characters) decided to go the 'single script route' (which worked for what I wanted to do).

The script above is a stripped down example of what I'm working with, and it does what I'm trying to do with one exception: When it displays the generated picture, if I try to save the picture by right-clicking and selecting "save as", it isn't saving the picture. It only saves the php-output of the form.

Why is it doing that / what's the best way to get just that functionality?
Link to comment
https://forums.phpfreaks.com/topic/12121-php-gd-ifthen-behavior/#findComment-46253
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.