From 18bdba4700e268f713df7ddda1b92d37bfef3cf9 Mon Sep 17 00:00:00 2001 From: Lior Broshi Date: Wed, 22 Feb 2012 19:50:29 +0200 Subject: [PATCH] + replaced `for` with `foreach` to allow parsing of myvar[ID1],myvar[ID2] instead of myvar[] - this gives the option to work with IDs injected into the array + added option to make the original filename lowercase on the destination file. + added option to provide destination filemask while using the {i} which represents the iterator in the foreach (Which is the given ID) I'm new to git hope I commited it right! ;-) --- MY_Upload.php | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/MY_Upload.php b/MY_Upload.php index a18400f..da6e278 100644 --- a/MY_Upload.php +++ b/MY_Upload.php @@ -1,12 +1,36 @@ ' . $count ); - - for($i = 0; $i < $count; $i++) + + foreach ( $_FILES[$field]['name'] as $i => $value ) { // Was the file able to be uploaded? If not, determine the reason why. @@ -84,6 +108,16 @@ public function do_multi_upload( $field = 'userfile', $return_info = TRUE ){ return FALSE; } + // Lowercase extension + if ( $lowercase_ext == TRUE ) { + $this->file_ext = strtolower($this->file_ext); + } + + // Rename destination filename + if ( !empty($new_file_name) ) { + $this->file_name = str_replace('{i}',$i,$new_file_name) . $this->file_ext; + } + // if we're overriding, let's now make sure the new name and type is allowed if ($this->_file_name_override != '') { @@ -131,7 +165,7 @@ public function do_multi_upload( $field = 'userfile', $return_info = TRUE ){ // Sanitize the file name for security $this->file_name = $this->clean_file_name($this->file_name); - + // Truncate the file name if it's too long if ($this->max_filename > 0) { @@ -234,5 +268,3 @@ public function do_multi_upload( $field = 'userfile', $return_info = TRUE ){ } } - -?> \ No newline at end of file