TAILIEUCHUNG - Beginning PHP6, Apache, MySQL Web Development- P8

Beginning PHP6, Apache, MySQL Web Development- P8:Welcome to Beginning PHP6, Apache, MySQL Web Development , your new trusty resource for assistance in creating your own dynamic web sites. There are a lot of technologies available that can be used to deliver great web sites, and we ’ re glad you chose the Apache/MySQL/PHP (sometimes referred to simply as AMP) approach. You may or may not have had a taste of these three components in the past, but either way we ’ re confident that you will be impressed with the power that lies within them | Chapter 7 Manipulating and Creating Images with PHP . image_caption . . image_username . . image_date . result mysql_query query db or die mysql_error db retrieve the image_id that MySQL generated automatically when we inserted the new record last_id mysql_insert_id because the id is unique we can use it as the image name as well to make sure we don t overwrite another image that already exists imagename last_id . ext update the image table now that the final filename is known. query UPDATE images SET image_filename . imagename . WHERE image_id . last_id result mysql_query query db or die mysql_error db save the image to its final destination switch type case IMAGETYPE_GIF imagegif image dir . break case IMAGETYPE_JPEG . imagename imagejpeg image dir . break case IMAGETYPE_PNG . . imagename 100 imagepng image dir . break imagedestroy image . imagename html head title Here is your pic title head body h1 So how does it feel to be famous h1 p Here is the picture you just uploaded to our servers p img src images php echo imagename style float left table tr td Image Saved as td td php echo imagename td tr tr td Image Type td td php echo ext td tr tr td Height td td php echo height td tr tr td Width td td php echo width td tr tr td Upload Date td td php echo image_date td tr table body html 7. Save this file as . 8. Now open in your browser. The page will load and your screen should look like Figure 7-2. 181 Part I Movie Review Web Site Figure 7-2 9. Upload your image. Your page should now look something like Figure 7-3. Figure 7-3 182 Chapter 7 Manipulating and Creating Images with PHP How It Works In you have given the HTML form the ability to accept files simply by doing two things. The first is using the file type input element. The input element now displays a Browse button next to the text area which allows a visitor to surf his or her local disk and populate the field with the file s path. The second is specifying

TỪ KHÓA LIÊN QUAN
TÀI LIỆU HOT