Changeset 2645
- Timestamp:
- 05/06/08 15:19:02 (3 months ago)
- Files:
-
- trunk/system/helpers/upload.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/system/helpers/upload.php
r2469 r2645 40 40 $directory = Config::item('upload.directory', TRUE); 41 41 } 42 else 43 { 44 // Make sure the directory ends with a slash 45 $directory = rtrim($directory, '/').'/'; 46 } 42 43 // Make sure the directory ends with a slash 44 $directory = rtrim($directory, '/').'/'; 47 45 48 46 if ( ! is_writable($directory)) … … 61 59 62 60 /** 63 * Tests if a $_FILES item is valid.61 * Tests if a $_FILES item exists. 64 62 * 65 * @param array $_FILES item66 * @return bool ean63 * @param array $_FILES item 64 * @return bool 67 65 */ 68 public static function valid($file)66 public static function required() 69 67 { 70 68 return (is_array($file) … … 73 71 AND isset($file['type']) 74 72 AND isset($file['tmp_name']) 75 AND isset($file['size']) 73 AND isset($file['size'])); 74 } 75 76 /** 77 * Tests if a $_FILES item is valid. 78 * 79 * @param array $_FILES item 80 * @return bool 81 */ 82 public static function valid($file) 83 { 84 return (isset($file['tmp_name']) 85 AND isset($file['error']) 76 86 AND is_uploaded_file($file['tmp_name']) 77 87 AND $file['error'] === UPLOAD_ERR_OK); … … 83 93 * @param array $_FILES item 84 94 * @param array allowed file extensions 85 * @return bool ean95 * @return bool 86 96 */ 87 97 public static function type(array $file, array $allowed_types) 88 98 { 89 99 // Get the default extension of the file 90 $extension = strtolower( preg_replace('/^.+\.(.+?)$/', '$1',$file['name']));100 $extension = strtolower(file::extension($file['name'])); 91 101 92 102 // Get the mime types for the extension … … 105 115 * @param array $_FILES item 106 116 * @param array maximum file size 107 * @return bool ean117 * @return bool 108 118 */ 109 119 public function size(array $file, array $size)
