PHP MVC Framework SKYMVC Support multi-File Upload implementation method

Source: Internet
Author: User
This article mainly for you in detail the PHP MVC framework skymvc File Upload implementation code, support multi-file upload operation, interested in small partners can refer to

Specific content is as follows

1. Code upload.ctrl.php

<?phpclass Uploadcontrol extends skymvc{public   function __construct () {  parent::__construct ();}   Public Function Ondefault () {     $this->smarty->display ("upload/default.html");}   Public Function Onupload () {     $this->loadclass ("Upload");  Uploaded file directory  $this->upload->uploaddir= "attach/my/";  File size allowed to upload  $this->upload->maxsize=4194304000;  Do you want to upload a picture  $this->upload->upimg=true;  Set the file types allowed to upload  $this->upload->sysallowtype=array (' gif ', ' jpg ', ' bmp ', ' png ', ' jpeg ', ' txt ', ' mpeg ', ' avi ', ' RM ', ' rmvb ', ' wmv ', ' flv ', ' mp3 ', ' wav ', ' wma ', ' SWF ', ' Doc ', ' pdf ', ' zip ', ' tar ', ' svg ');  $this->upload->allowtype= $this->upload->sysallowtype;  Store  $this->upload->iddir=0;  by ID $data = $this->upload->uploadfile ("upimg");  Print_r ($data);  echo Json_encode ($data);     }      } ?>

2. Code upload.html

<!doctype html>

3.PHP Code

function Skyupload (upid,url,success,error,uploadprogress) {   var VFD = new FormData ();   var f= document.getElementById (upid). files;   $ ("#" +upid+ "Loading"). Show ();   for (Var i=0;i<f.length;i++) {    vfd.append (' upimg ', document.getElementById (upid). Files[i]);   var oxhr = new XMLHttpRequest ();     Oxhr.addeventlistener (' Load ', success, false);   Oxhr.addeventlistener (' Error ', error, false);   if (uploadprogress!=undefined) {    OXHR.upload.addEventListener ("Progress", uploadprogress, False);   }   Oxhr.open (' POST ', url);   Oxhr.send (VFD);}     } /*function Uploadfinish (e) {  var data=eval ("(" +e.target.responsetext+ ")");  $ ("#uploading"). Hide ()  if (data.error! = ")  {   skytoast (data.msg);  } Else  {   $ ("#imgShow"). HTML ("

Summary: The above is the entire content of this article, I hope to be able to help you learn.

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.