TAILIEUCHUNG - ASP.NET 4 Unleased - p 22

Sử dụng điều khiển Rich Các trang web bao gồm một phương thức có tên CheckFileType (), trong đó ngăn người dùng tải lên một tập tin mà không có gif., jpeg, jpg, hoặc. png mở rộng. Phương pháp này hạn chế các loại tập tin có thể được tải lên dựa trên phần mở rộng tập tin. | 184 CHAPTER 4 Using the Rich Controls The page includes a method named CheckFileType which prevents users from uploading a file that does not have the .gif .jpeg .jpg or .png extension. The method restricts the type of file that can be uploaded based on the file extension. NOTE The HTML specifications define an accept attribute that you can use to filter the files that can be uploaded. Unfortunately no browser supports the accept attribute so you must perform filtering on the server or use some JavaScript to check the filename extension on the client . To save a file to the file system the Windows account associated with the page must have sufficient permissions to save the file. For Windows 2003 and Windows 2008 servers an page executes in the security context of the NETWORK SERVICE account. In the case of every other operating system an page executes in the security context of the ASPNET account. To enable Framework to save an uploaded file to a particular folder you need to right-click the folder within Windows Explorer select the Security tab and provide either the NETWORK SERVICE or ASPNET account Write permissions for the folder see Figure . FIGURE Adding Write permissions for the ASPNET account. From the Library of Wow eBook Accepting File Uploads 185 Saving Files to a Database You also can use the FileUpload control to save files to a database table. Saving and retrieving files from a database can place more stress on your server. However it does have certain advantages. First you can avoid file system permissions issues. Second saving files to a database enables you to more easily back up your information. The page in Listing enables you to save Microsoft Word documents to a database table see Figure . LISTING @ Page Language C @ Import Namespace DOCTYPE html PUBLIC - W3C DTD XHTML Transitional EN http TR xhtml1 DTD script runat

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.