/** * File upload * Perform the upload with all required checks: file size, image size form images (crop and resize), check for overwrite and add prefixes, store the file inthe right folder. * * @param string the name of the field * @param string the path where to store the file. The standard path is APATH.'files/filemanager/ ' * @param string a prefix for the filename * @param boolean zip the file if it not an image and is set to true * @param array the array contains (maximum width, maximum height, action_string, maximum file weight (kBytes) for images, maximum file weight (KBytes) for others documents). Possibles values for the action string are: 'NONE', 'CROP', 'RESIZE' * @param array the array contains valid mime types * @return mixed the filename string if upload only a file, an array of filename if upload many files */ public static function upload($file, $path, $prefix = '', $zip = 0, $limits = array(MAX_W, MAX_H, 'NONE', MAX_IMG, MAX_DOC), $mimes = array()) { if (isset($_GET[$file])) { self::$file = new Upload_file_xhr($file); return X4Files_helper::gupload_file($file, $path, $prefix, $zip, $limits, $mimes); } else { if (isset($_FILES[$file])) { return is_array($_FILES[$file]['name']) ? X4Files_helper::upload_files($file, $path, $prefix, $zip, $limits, $mimes) : X4Files_helper::upload_file($file, $path, $prefix, $zip, $limits, $mimes); } } }