Thinkphp can not realize the upload of RAR file, I hope you pointed out
thinkphp implementation file upload, RAR format can not be uploaded, Pdf,jpg,xls file upload
PHP Code
Public function upload () { if (!empty ($_files)) { echo ' OK '; Dump ($_files); If there is a file upload, upload the attachment $this->_upload (); } else{ echo ' no '; Dump ($_files); } }
After submitting the RAR format file, judge the submitted data is empty;
If the Pdf,jpg,xls file is submitted, the submitted data is judged to be normal and the upload is successful.
------Solution--------------------
PHP Code
Public function upload () {import (' ORG. Net.uploadfile '); $upload = new UploadFile ();//Instantiate upload class $upload->maxsize = 3145728;//Set attachment upload size $upload->allowexts = a Rray (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type $upload->savepath = './public/uploads/';//Set Attachments upload directory if (! $upload Upload ()) {//Upload error message $this->error ($upload->geterrormsg ());} else{//upload successfully obtained upload file information $info = $upload->getuploadfileinfo ();}//Save the form data including the attachment data $user = M ("User"); Instantiate the User object $user->create (); Create data Object $user->photo = $info [0][' Savename ']; Save uploaded photos Assemble $user->add () as needed; Write user data to database $this->success (' Data saved successfully! ');}
------Solution--------------------
TP inside the upload does not support file upload rar format, you can write your own upload class to achieve
Explore
PHP Code
Public function upload () {
Import (' ORG.Net.UploadFile ');
$upload = new UploadFile ();//instantiation of upload class
$upload->maxsize = 3145728;//Set attachment upload size
$upload->allowexts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ' ...
------Solution--------------------
$upload->allowexts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type