# PHPCrazy.Class.codeguy.Upload **Repository Path**: newzhangyun/PHPCrazy.Class.codeguy.Upload ## Basic Information - **Project Name**: PHPCrazy.Class.codeguy.Upload - **Description**: PHPCrazy 多文件上传类 - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2015-12-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #PHPCrazy.Class.Upload.brandonsavage PHPCrazy多文件上传类,需要支持 **php_fileinfo** 扩展 ##如何使用?? 下载[Crazy / PHPCrazy.Class.Upload.brandonsavage](http://git.oschina.net/Crazy-code/PHPCrazy.Class.Upload.brandonsavage/repository/archive/master),解压到PHPCrazy根目录 ##实例 ###HTML ```html
``` ###PHP ```php setName($new_filename); // Validate file upload // MimeType List => http://www.iana.org/assignments/media-types/media-types.xhtml $file->addValidations(array( // Ensure file is of type "image/png" new \Upload\Validation\Mimetype('image/png'), //You can also add multi mimetype validation //new \Upload\Validation\Mimetype(array('image/png', 'image/gif')) // Ensure file is no larger than 5M (use "B", "K", M", or "G") new \Upload\Validation\Size('5M') )); // Access data about the file that has been uploaded $data = array( 'name' => $file->getNameWithExtension(), 'extension' => $file->getExtension(), 'mime' => $file->getMimetype(), 'size' => $file->getSize(), 'md5' => $file->getMd5(), 'dimensions' => $file->getDimensions() ); // Try to upload file try { // Success! $file->upload(); } catch (\Exception $e) { // Fail! $errors = $file->getErrors(); } ```