This example for you to share the SKYMVC implementation of file upload specific code, for your reference, the specific content as follows
1. Code upload.ctrl.php
<?php
class 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;
Whether to upload pictures
$this->upload->upimg=true;
Set the file types that are allowed to be uploaded
$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
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 (" ');
$ ("#imgurl"). Val (Data.imgurl); } function Uploaderror (e) {//Upload error Skytoast ("Out of Error");} */
The above is the entire content of this article, I hope that you learn PHP program help.