Managed web hosting - Next you decide whether or not you want
Next you decide whether or not you want to keep the changes you are making, and you do so in the following lines: if ($action == preview ) { header( Content-type:image/jpeg ); imagejpeg($image); } If you are only previewing the image, you will spit it directly out to the browser (which is done using the imagejpeg() function and without a specific filename for the destination). But why did you send a header to the browser, and why is there no HTML? Again, because you are spitting out the image directly, you don t need (and actually can t send) any text along with the image. You are only sending the image itself. If you don t specify what content type is in your page, the browser will assume it is text and you will get a page full of garbage. Don t believe us? Go ahead and comment out the header line and reload the page. See what we mean? You send the header so the browser will interpret the image stream correctly. Because the browser is expecting an image, if you try to send any text along with the image, after the header has been sent, you will see a big ol error. If your users want to save the changes to the image, and they click save when submitting, you process the following lines of code: if ($action == save ) { imagejpeg($image, $image_filename); $url = location:showimage.php?id= . $id . &mode=change ; header($url); } Notice the use of the mode variable (so your users will see the confirmation text when the page loads) and the filename specified in the imagejpeg() function. Specifying a destination filename saves the temporary image to a permanent place, and in this case, it overwrites the file that was already there, making your change permanent. Think you got it? Great! Let s let your users play with their images some more, shall we? Adding Captions A special group of functions allow you to add captions (or a copyright notice or other text) to your images. PHP/GD is relatively advanced in allowing you to control the size and type of font that is used, even allowing you to load your own font on demand. While you re absolutely encouraged to experiment with all the cool font functions available to you, we will try and keep it simple here to get you started. That being said, let s get to it! 214 Chapter 7
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.