首页
开发手册
应用中心
工具
用户中心
FoundPHP Upload file
English
中文简体
English
上一篇
下一篇
###FoundPHP Upload Files Foundphp upload file framework integrates upload file components, just set the name of 'from' and 'file'. **Examples:** Using browser: http://localhost/dev/?a=test ![](data/files/edit/21/02/21/210221_23067274.png) We build a test model,add form, verifying 、 receiving and storing. 'plugin/model' Create a test directory under the directory,establish 'default.php' **Module file:** plugin/model/test/default.php ```php save(array( 'id' => 'attach', //Form submission element name 'maxsize' => '8000', //Upload restricted units (kb) 'width' => '1400', //The width is only valid for the image, and the width and height must be assigned at the same time 'height' => '1000', //Height is only valid for image, width and height must be assigned at the same time 'dir' => 'data/files/'.dates(time(),'Ym').'/', //Storage path 'name' => rand(1000,9999), //Storage file name 'type' => array('jpg','jpeg','png'), //Supported formats )); //Print upload file print_r($files); exit; } ?> ``` **Output results:** Array ( [id] => attach [width] => 0 [height] => 0 [ext] => png [upfile] => FoundPHP code.png [upname] => foundphp code [filesize] => 15273 [filename] => 9130.png [dir] => data/files/202102/ [error] => 0 [code] => 1 ) `When the output result appears, it proves that the file already exists and renames the source file。 data/files/202102/9130.png` --- FoundPHP_upload Upload parameter description | parameter | explain | | ------------ | ------------ | | id | The name of the file in the view template | | maxsize | Maximum KB of files allowed to be uploaded | | width | Maximum photo width (non photo does not affect) | | height | Maximum height of photo (not affected by photo) | | dir | Photo saving directory supports automatic directory creation | | name | Save file name | | type | Upload supported formats | | cut | Upload supported formats | | zoom | Zoom photos | **view file:** plugin/view/default/ Create test directory under directory,establish default.htm plugin/view/default/test/default.htm ```html
photo
save
``` `Remember to add enctype="multipart/form-data" in the form to upload files`