TAILIEUCHUNG - Beginning asp net 2.0 with c phần 5

saveFile = (savePath, ) (saveFile); / / Hiển thị trạng thái của sự thành công = "file của bạn đã được tải lên thành công.";} catch (Exception exUpload) {/ / hiển thị trạng thái lỗi ;}} else {/ / có thể tập tin không phải là lựa chọn / trạng thái / Hiển thị của sự thất bại = "Bạn không chỉ định một tập tin để tải lên.";} . | Chapter 8 saveFile savePath saveFile Displays status of success Your file was uploaded successfully. catch Exception exUpload display status of error else probably file was not selected Display status of failure You did not specify a file to upload. In the following Try It Out you give users a way to add pictures to the gallery. Try It Out Uploading Files Basic 1. Using VWD create a new page named using the Web Form template. As you have with most pages up to this point use the as the Master page use Visual C and enable the option to place the code on a separate page. 2. In Design View add a FileUpload control from the Toolbox and a Label control that will have an ID of FileUploadReport with an empty text property. Also add a button control with the text property set to Upload . 3. Double-click the button to go to its code. Add the following shaded code to the Sub using System using using . public partial class GalleryUpload protected void Buttonl_Click object sender EventArgs e string ImagesFolder Matchimages string savePath string saveFile if try perform the upload savePath ImagesFolder saveFile savePath saveFile Displays status of success Your file was uploaded successfully. catch Exception exUpload 276 Writing Data display status of error else probably file was not selected Display status of failure You did not specify a file to upload. 4. Save the page and view it in your browser see Figure 8-11 . You probably won t have pictures of the hapless Wrox United tumblers but you can try uploading any jpeg or gif you have on your hard drive. Figure 8-11 How It Works The FileUpload control .

TỪ KHÓA LIÊN QUAN
Đã 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.