首页
开发手册
应用中心
工具
用户中心
FoundPHP Base64 File Upload
English
中文简体
English
上一篇
下一篇
### FoundPHP BASE64 File Upload In many cases, in order to facilitate users to preview the contents of uploaded files, base64 files are used for uploading, so how to receive base64 files? #### 1.Use the form to submit base64 files ```html
``` #### 2.PHP receives base64 files When receiving, pay attention to the data: parameter of the base64 file. Different file formats are different. For example, the MP3 file is `data:audio/mp3;`, and the PNG image file is `data:image/png;` ```php //Split base64 according to different files $files = explode('base64,',$P['base_upload']); $files_content = base64_decode($files[1]);//decode file content //file path $dirs = 'data/files/'.dates(time(),'ymd').'/'; if(!is_dir($dirs)){ $tpl->mk_dir($dirs); } //file name $filename = rand(1000,9999).'.jpg'; //Write file $tpl->writer($dirs.$filename,$files_content); //store the file path in the database ```