Skip to content

Latest commit

 

History

History
23 lines (22 loc) · 921 Bytes

README.md

File metadata and controls

23 lines (22 loc) · 921 Bytes

upload

A simple upload class of php.

usage

Depends on a OO file object, like Phalcon\Http\Request\File and FileInfo, or you can implement your own file class.

$config = [
      'scene1' => [
           'baseDir' => 'path/to/save/images/',
           'urlPrefix' => '/website/upload/images/',
           'rules' => [
               'size' => [1000000, '文件大小不超过1M'],
               'type' => [['image/jpeg', 'image/png'], 'Only jpg and png allowed'],
               'exts' => [['jpg', 'png'], 'Only jpg and png allowed'],
               'dims' => [[600,800], 'Required image width is 600 and height is 800']
           ]
      ]
];
  
$uploader = new Uploader($config);
if (!$uploader->upload($file)) {
  echo $uploader->getError();
}