thinkphp implementation of RAR file upload, I hope you point out how to solve

Source: Internet
Author: User
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.

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! ');}
TP inside the upload does not support file upload rar format, you can write your own upload class to achieve


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 ' ...

$upload->allowexts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.