Thinkphp+uploadify Photo Upload Example Tutorial

Source: Internet
Author: User

Thinkphp+uploadify Photo Upload Example Tutorial

First, unzip the downloaded Uploadify compressed package into a public folder. The implementation code is as follows: 1, foreground HTML section:

    1. Upload



Copy Code

2,action Execution Code section:

  1. Public Function uploadify ()
  2. {
  3. $ph =m (' Upload ');
  4. Import (' ORG.Net.UploadFile ');
  5. $upload = new UploadFile ();//instantiation of upload class
  6. $upload->maxsize = 93145728;//Set attachment upload size
  7. $upload->saverule =rand (1,9999);
  8. $upload->allowexts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ', ' flv ', ' avi ', ' mov ');//Set attachment upload type
  9. $upload->savepath = './uploads/';//Set Attachments upload Directory
  10. if (! $upload->upload ())
  11. {//Upload error message
  12. $this->error ($upload->geterrormsg ());
  13. }else{//Upload successfully uploaded file information
  14. $info = $upload->getuploadfileinfo ();
  15. }
  16. for ($i =0; $i<>
  17. {
  18. $data [' name ']= $info [$i] [' savename '];
  19. $data [' Size ']= $info [$i] [' size '];
  20. $data [' type ']= $info [$i] [' extension '];
  21. echo $info [$i] [' savename '];
  22. $rs = $ph->add ($data);
  23. }
  24. /*if ($RS)
  25. {
  26. $this->success ("Success");
  27. }else
  28. {
  29. $this->error ("failure");
  30. }*/
  31. }
Copy Code
  • 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: info-contact@alibabacloud.com 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.