thinkPHP+Uploadify image upload tutorial

WBOY
Release: 2016-07-25 09:11:54
Original
947 people have browsed it

thinkPHP+Uploadify image upload tutorial

First, unzip the downloaded Uploadify compressed package and put it in the public folder. The implementation code is as follows: 1. Frontend html part:

  1. Upload



Copy code

2, action execution code part:

  1. public function uploadify()
  2. {
  3. $ph=M('Upload');
  4. import('ORG.Net.UploadFile');
  5. $upload = new UploadFile(); // Instantiate upload Class
  6. $upload->maxSize = 93145728 ;//Set the attachment upload size
  7. $upload->saveRule =rand(1,9999);
  8. $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg','flv','avi','mov');//Set the attachment upload type
  9. $upload->savePath = './Uploads/';//Set the attachment upload directory
  10. if (!$upload->upload())
  11. {// Upload error prompt error message
  12. $this->error($upload->getErrorMsg());
  13. }else{// Upload successfully to obtain uploaded file information
  14. $info = $upload->getUploadFileInfo();
  15. }
  16. for($i=0;$i {
  17. $data['name']=$info[$ i]['savename'];
  18. $data['size']=$info[$i]['size'];
  19. $data['type']=$info[$i]['extension'];
  20. echo $info[$i]['savename'];
  21. $rs=$ph->add($data);
  22. }
  23. /*if($rs)
  24. {
  25. $this->success(" Success");
  26. }else
  27. {
  28. $this->error("Failure");
  29. }*/
  30. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!