tailieunhanh - php solutions dynamic web design made easy phần 6

Chọn một hình ảnh từthả xuống và nhấn vào nút Create thumbnail. Nếu mọi việc suôn sẻ, có phải là một phiên bản scaleddown của hình ảnh mà bạn đã chọn trong các thư mục con ngón tay cái của . Kiểm tra mã của bạn, nếu cần thiết, có .php trong các tập tin tải về. | GENERATING THUMBNAIL IMAGES In spite of its destructive name imagedestroy has no effect on the original image nor on the thumbnail that s just been saved to file. The function simply frees up the server memory by destroying the image resources required during processing. 8. Before testing the page you need to add some code just after the opening body tag to display the message reporting the outcome like this body php if isset result echo p result p form id form1 name form1 method post action 9. Save and load it in a browser. Select an image from the drop-down menu and click Create thumbnail. If all goes well there should be a scaled-down version of the image you chose in the thumbs subfolder of upload_test. Check your code if necessary with in the download files. Resizing an image automatically on upload Now that you have a script that creates a thumbnail from a larger image it takes only a few minor changes to merge it with the file upload script from Chapter 6. Rather than build the entire script in a single page this is a good opportunity to use a PHP include includes were covered in Chapter 4 . 8 PHP Solution 8-3 Merging the image upload and resizing scripts The starting point for this PHP Solution is from the preceding section together with from Chapter 6. Alternatively use and from the download files for this chapter. The finished scripts are in and . 1. In select the entire PHP block above the DOCTYPE declaration. Copy the selected code to your computer clipboard and paste it inside a blank PHP page. The new page should contain PHP script only you don t need a DOCTYPE or XHTML skeleton. Save the page in the includes folder as . 2. Remove the comment on line 2 together with the conditional statement that surrounds the script don t forget the closing curly brace just before the closing

TỪ KHÓA LIÊN QUAN