Max. filesize = bytes.<\/p> \n
show_error_string(); ?><\/p> \n\".nl2br($info).\"<\/blockquote>\"; ?> \n<\/body> \n<\/html><\/pre>\n
3,多文件上傳的例子<\/p>\n
\nlanguage) { \n case \"de\": \n \/\/ add you translations here \n break; \n default: \n $extra_msg[1] = \"Error for: \".$this->the_file.\"<\/b>\"; \n $extra_msg[2] = \"You have tried to upload \".$this->wrong_extensions.\" files with a bad extension, the following extensions\n are allowed: \".$this->ext_string.\"<\/b>\"; \n $extra_msg[3] = \"Select at least on file.\"; \n $extra_msg[4] = \"Select the file(s) for upload.\"; \n $extra_msg[5] = \"You have tried to upload \".$this->bad_filenames.\" files<\/b> with invalid characters inside the filename.\"; \n } \n return $extra_msg[$msg_num]; \n } \n \/\/ this method checkes the number of files for upload \n \/\/ this example works with one or more files \n function count_files() { \n foreach ($this->names_array as $test) { \n if ($test != \"\") { \n $this->number_of_files++; \n } \n } \n if ($this->number_of_files > 0) { \n return true; \n } else { \n return false; \n } \n } \n function upload_multi_files () { \n $this->message = \"\"; \n if ($this->count_files()) { \n foreach ($this->names_array as $key => $value) { \n if ($value != \"\") { \n $this->the_file = $value; \n $new_name = $this->set_file_name(); \n if ($this->check_file_name($new_name)) { \n if ($this->validateExtension()) { \n $this->file_copy = $new_name; \n $this->the_temp_file = $this->tmp_names_array[$key]; \n if (is_uploaded_file($this->the_temp_file)) { \n if ($this->move_upload($this->the_temp_file, $this->file_copy)) { \n $this->message[] = $this->error_text($this->error_array[$key]); \n if ($this->rename_file) $this->message[] = $this->error_text(16); \n sleep(1); \/\/ wait a seconds to get an new timestamp (if rename is set) \n } \n } else { \n $this->message[] = $this->extra_text(1); \n $this->message[] = $this->error_text($this->error_array[$key]); \n } \n } else { \n $this->wrong_extensions++; \n } \n } else { \n $this->bad_filenames++; \n } \n } \n } \n if ($this->bad_filenames > 0) $this->message[] = $this->extra_text(5); \n if ($this->wrong_extensions > 0) { \n $this->show_extensions(); \n $this->message[] = $this->extra_text(2); \n } \n } else { \n $this->message[] = $this->extra_text(3); \n } \n } \n} \n\n$multi_upload = new muli_files; \n\n$multi_upload->upload_dir = $_SERVER['DOCUMENT_ROOT'].\"\/files\/\"; \/\/ \"files\" is the folder for the uploaded files (you have to create this folder) \n$multi_upload->extensions = array(\".png\", \".zip\"); \/\/ specify the allowed extensions here \n$multi_upload->message[] = $multi_upload->extra_text(4); \/\/ a different standard message for multiple files \n\/\/$multi_upload->rename_file = true; \/\/ set to \"true\" if you want to rename all files with a timestamp value \n$multi_upload->do_filename_check = \"y\"; \/\/ check filename ... \n \nif(isset($_POST['Submit'])) { \n $multi_upload->tmp_names_array = $_FILES['upload']['tmp_name']; \n $multi_upload->names_array = $_FILES['upload']['name']; \n $multi_upload->error_array = $_FILES['upload']['error']; \n $multi_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : \"n\"; \/\/ because only a checked checkboxes is true \n $multi_upload->upload_multi_files(); \n} \n?> \n \n \n \n \nphp多文件上傳的例子-bbs.it-home.org<\/title> \n