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.