首页
开发手册
应用中心
工具
用户中心
FoundPHP Single File Upload
English
中文简体
English
上一篇
下一篇
### FoundPHP Single File Upload In development, uploading pictures or files is the most frequent. FoundPHP provides a method of receiving files to make the development of programs more convenient. #### 1.Form Uploading files is the same as submitting data, and both need to rely on the form form. When the data is different from ordinary submission, the file upload needs to add the `enctype="multipart/form-data"` parameter in the form form. **Example** ```html
``` #### 2.File Receiving Receive the file submitted by the form in PHP, the FoundPHP framework has automatically referenced the FoundPHP file upload class (*If you are not using the FoundPHP framework, you need to quote this class*) ```php $files_dir = dates(time(),'Ym').'/'.dates(time(),'d').'/'; //judgment file receipt if($_FILES['upload']['name']){ $files = $FoundPHP_upload->save(array( 'id' => 'upload', //submit file element name in the form 'maxsize' => '40000', //Upload limit unit kb 'height' => '400', //height, only valid for pictures 'width' => '400', //width, only valid for pictures 'cut' => 1, //crop picture, choose one of zoom and zoom, only valid for picture 'zoom' => 1, //scaling the picture in proportion, choose one of cut and cut, only valid for picture 'lock' =>0, //0 width, width and height are not enough to fill the color, 1 zoom the maximum width of the photo, only valid for the image 'dir' => $FILE_DIR.$files_dir, //storage path 'name' => rand(1000,9999), //storage path 'type' => array('jpg','png','jpeg','mp3','mp4','mov'), //supported format 'json' => 1 //output json format )); } ``` #### 3.Receive Return Parameter Data | field | description| |-----|-----| |id |elements of file submission| |ext|file format| |upfile|upload file name plus suffix| |upname|upload file name without suffix| |filesize|file size| |filename|save file name| |dir|file save path| |code|1 for upload success, 0 for upload failure|