TAILIEUCHUNG - Giải pháp thiết kế web động với PHP - p 17

Chapter 6 Uploading Files PHP s ability to handle forms isn t restricted to text. It can also be used to upload files to a server. For instance, you could build a real estate website for clients to upload pictures of their properties or a site for all your friends and relatives to upload their holiday photos. However, just because you can do it, doesn t necessarily mean that you should. Allowing others to upload material to your website could expose you to all sorts of problems. You need to make sure that images are the right size, that they re of. | Chapter 6 Uploading Files PHP s ability to handle forms isn t restricted to text. It can also be used to upload files to a server. For instance you could build a real estate website for clients to upload pictures of their properties or a site for all your friends and relatives to upload their holiday photos. However just because you can do it doesn t necessarily mean that you should. Allowing others to upload material to your website could expose you to all sorts of problems. You need to make sure that images are the right size that they re of suitable quality and that they don t contain any illegal material. You also need to ensure that uploads don t contain malicious scripts. In other words you need to protect your website just as carefully as your own computer. PHP makes it relatively simple to restrict the type and size of files accepted. What it cannot do is check the suitability of the content. Think carefully about security measures such as restricting uploads to registered and trusted users by placing the upload form in a password-protected area. Until you learn how to restrict access to pages with PHP in Chapters 9 and 17 use the PHP solutions in this chapter only in a password-protected directory if deployed on a public website. Most hosting companies provide simple password protection through the site s control panel. The first part of this chapter is devoted to understanding the mechanics of file uploads which will make it easier to understand the code that follows. This is a fairly intense chapter not a collection of quick solutions. But by the end of the chapter you will have built a PHP class capable of handling single and multiple file uploads. You can then use the class in any form by writing only a few lines of code. You ll learn about the following Understanding the _FILES array Restricting the size and type of uploads Preventing files from being overwritten Organizing uploads into specific folders Handling multiple uploads 141 CHAPTER 6 How PHP

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.