Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added file prefix param to MooUpload::upload() method

  • Loading branch information...
commit 425e3d5d65dcd45c10c620e98541dadf9117ab19 1 parent 68970f1
Juan Lago authored

Showing 1 changed file with 8 additions and 7 deletions. Show diff stats Hide diff stats

  1. +8 7 Source/mooupload.php
15 Source/mooupload.php
@@ -36,12 +36,13 @@ public static function is_HTML5_upload()
36 36 *
37 37 * Upload a file using HTML4 or Flash method
38 38 *
39   - * @param string Directory destination path
  39 + * @param string Directory destination path
  40 + * @param string File prefix (Useful for avoid file overwriting)
40 41 * @param boolean Return response to the script
41 42 * @return array Response
42 43 *
43 44 */
44   - public static function HTML4_upload($destpath, $send_response = TRUE)
  45 + public static function HTML4_upload($destpath, $file_prefix = '', $send_response = TRUE)
45 46 {
46 47
47 48 // Normalize path
@@ -65,7 +66,7 @@ public static function HTML4_upload($destpath, $send_response = TRUE)
65 66
66 67 if ($response['error'] == 0)
67 68 {
68   - if (move_uploaded_file($file['tmp_name'], $destpath.$file['name']) === FALSE)
  69 + if (move_uploaded_file($file['tmp_name'], $destpath.$file_prefix.$file['name']) === FALSE)
69 70 $response['error'] = UPLOAD_ERR_NO_TMP_DIR;
70 71 else
71 72 $response['finish'] = TRUE;
@@ -90,7 +91,7 @@ public static function HTML4_upload($destpath, $send_response = TRUE)
90 91 * @return array Response
91 92 *
92 93 */
93   - public static function HTML5_upload($destpath, $send_response = TRUE)
  94 + public static function HTML5_upload($destpath, $file_prefix = '', $send_response = TRUE)
94 95 {
95 96
96 97 // Normalize path
@@ -148,7 +149,7 @@ public static function HTML5_upload($destpath, $send_response = TRUE)
148 149 $response['finish'] = TRUE;
149 150
150 151 /* If uploaded file is finished, maybe you are interested in saving, registering or moving the file */
151   - // my_save_file($destpath.$filename, $response['name']);
  152 + // my_save_file($destpath.$filename, $file_prefix.$response['name']);
152 153 }
153 154 }
154 155
@@ -175,9 +176,9 @@ public static function HTML5_upload($destpath, $send_response = TRUE)
175 176 * @return array Response
176 177 *
177 178 */
178   - public static function upload($destpath, $send_response = TRUE)
  179 + public static function upload($destpath, $file_prefix = '', $send_response = TRUE)
179 180 {
180   - return self::is_HTML5_upload() ? self::HTML5_upload($destpath, $send_response) : self::HTML4_upload($destpath, $send_response);
  181 + return self::is_HTML5_upload() ? self::HTML5_upload($destpath, $file_prefix, $send_response) : self::HTML4_upload($destpath, $file_prefix, $send_response);
181 182 }
182 183
183 184

0 comments on commit 425e3d5

Please sign in to comment.
Something went wrong with that request. Please try again.