Changeset 2648
- Timestamp:
- 05/06/08 21:47:22 (2 months ago)
- Files:
-
- trunk/system/helpers/upload.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/system/helpers/upload.php
r2647 r2648 16 16 * Save an uploaded file to a new location. 17 17 * 18 * @param string name of $_FILE input18 * @param mixed name of $_FILE input or array of upload data 19 19 * @param string new filename 20 20 * @param string new directory 21 21 * @return string full path to new file 22 22 */ 23 public function save($ name, $filename = NULL, $directory = NULL)23 public function save($file, $filename = NULL, $directory = NULL) 24 24 { 25 // Load file data from FILES if not passed as array 26 $file = is_array($file) ? $file : $_FILES[$file]; 27 25 28 if ($filename === NULL) 26 29 { 27 30 // Use the default filename, with a timestamp pre-pended 28 $filename = time().$ _FILES[$name]['name'];31 $filename = time().$file['name']; 29 32 } 30 33 … … 47 50 throw new Kohana_Exception('upload.not_writable', $directory); 48 51 49 if (is_uploaded_file($ _FILES[$name]['tmp_name']) AND move_uploaded_file($_FILES[$name]['tmp_name'], $filename = $directory.$filename))52 if (is_uploaded_file($file['tmp_name']) AND move_uploaded_file($file['tmp_name'], $filename = $directory.$filename)) 50 53 { 51 54 // Move the file to the upload directory … … 80 83 * @return bool 81 84 */ 82 public static function valid( $file)85 public static function valid(array $file) 83 86 { 84 87 return (isset($file['tmp_name']) 85 88 AND isset($file['error']) 86 89 AND is_uploaded_file($file['tmp_name']) 87 AND $file['error'] === UPLOAD_ERR_OK);90 AND (int) $file['error'] === UPLOAD_ERR_OK); 88 91 } 89 92
