TAILIEUCHUNG - php solutions dynamic web design made easy phần 5

Chức năng chỉ đơn giản là giải phóng bộ nhớ máy chủ bằng cách phá hủy các tài nguyên hình ảnh cần thiết trong quá trình chế khi kiểm tra trang, bạn cần phải thêm một số mã chỉ sau khi mởTiết kiệm và tải nó trong trình duyệt. | UPLOADING FILES convert the maximum size to KB max number_format MAX_FILE_SIZE 1024 1 . KB create an array of permitted MIME types permitted array image gif image jpeg image pjpeg image png foreach _FILES image name as number file replace any spaces in the filename with underscores file str_replace _ file begin by assuming the file is unacceptable sizeOK false typeOK false check that file is within the permitted size if _FILES image size number 0 _FILES image size number MAX_FILE_SIZE sizeOK true check that file is of a permitted MIME type foreach permitted as type if type _FILES image type number typeOK true break if sizeOK typeOK switch _FILES image error number case 0 check if a file of the same name has been uploaded if file_exists UPLOAD_DIR. file move the file to the upload folder and rename it success move_uploaded_file _FILES image tmp_name number UPLOAD_DIR. file else get the date and time ini_set Europe London now date Y-m-d-His success move_uploaded_file _FILES image tmp_name number UPLOAD_DIR. now. file if success result file uploaded successfully else result Error uploading file. Please try again. break 6 175 PHP SOLUTIONS DYNAMIC WEB DESIGN MADE EASY case 3 result Error uploading file. Please try again. default result System error uploading file. Contact webmaster. elseif _FILES image error number 4 result No file selected else result file cannot be uploaded. Maximum size max. Acceptable file types gif jpg png. The key line in this code is line 13 which looks like this foreach _FILES image name as number file When two files are uploaded simultaneously the name part of the array looks like this _FILES image name 0 _FILES image name 1 By looping through _FILES image name on the first iteration number is 0 and file is . The next time the loop runs number is 1 and file is . This does the same as the following line in the original script file _FILES image name The added bonus is that number gives you access

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.