欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP MVC框架skymvc支持多文件上傳

 更新時(shí)間:2016年05月26日 14:18:37   作者:雷神之光  
這篇文章主要為大家詳細(xì)介紹了php mvc框架skymvc文件上傳實(shí)現(xiàn)代碼,支持多文件上傳操作,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了skymvc實(shí)現(xiàn)文件上傳的具體代碼,供大家參考,具體內(nèi)容如下

1.代碼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");
  //上傳的文件目錄
  $this->upload->uploaddir="attach/my/";
  //允許上傳的文件大小
  $this->upload->maxsize=4194304000;
  //是否上傳圖片
  $this->upload->upimg=true;
  //設(shè)置允許上傳的文件類型
  $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;
  //根據(jù)Id存儲(chǔ)
  $this->upload->iddir=0;
  $data=$this->upload->uploadfile("upimg");
  //print_r($data);
  echo json_encode($data); 
   
 }
  
  
  
}
 
?>

2.代碼upload.html    

<!doctype html>
<html>
{include file="head.html"}
 
<body>
 
{include file="header.html"}
<div class="main-body box960">
 <form method="post" action="/index.php?m=upload&a=upload" enctype="multipart/form-data">
 <div class="row">
  <div class="btn-upload">
   <i class="iconfont icon-upload"></i>
   上傳文件
   <div class="btn-upload-file">
    <input type="file" id="upimg" name="upimg" multiple>
    </div>
  </div>
 </div>
 <div style="height:10px;"></div>
 <div class="row">
 <input type="submit" class="btn" value="上傳">
 </div>
 </form>
 <h3>上傳結(jié)果</h3>
 <div class="result" id="result"></div>
</div>
{include file="footer.html"}
<style>
 .result{border:1px solid #ccc; padding:5px;}
 .result div{line-height:24px;}
 .result .e{color:#D58384;}
 .result .s{color:#59A42A;}
</style>
<script src="/static/js/skyupload.js"></script>
<script>
 $(document).on("change","#upimg",function(data){
  skyUpload("upimg","/index.php?m=upload&a=upload&ajax=1",function(e){
   var data=eval("("+e.target.responseText+")");
   if(data.err){
    $("#result").append('<div class="e">error:'+data.err+'</div>');
   }else{
    $("#result").append('<div class="s">success:'+data.filename+'</div>');
   }
  });
 });
</script>
</body>
</html>

3.PHP代碼

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("<img src='/"+data.imgurl+".100x100.jpg' width='100'>");
   $("#imgurl").val(data.imgurl);
   }
}
  
function uploadError(e) { // upload error
  skyToast("上傳出錯(cuò)了");
}
*/

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)php程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 詳解WordPress中過濾鏈接與過濾SQL語(yǔ)句的方法

    詳解WordPress中過濾鏈接與過濾SQL語(yǔ)句的方法

    這篇文章主要介紹了詳解WordPress中過濾鏈接與過濾SQL語(yǔ)句的方法,主要用于防止不安全協(xié)議和SQL注入攻擊,需要的朋友可以參考下
    2015-12-12
  • PHP遞歸遍歷文件夾去除注釋并壓縮php源代碼的方法示例

    PHP遞歸遍歷文件夾去除注釋并壓縮php源代碼的方法示例

    這篇文章主要介紹了PHP遞歸遍歷文件夾去除注釋并壓縮php源代碼的方法,涉及php文件與目錄的遍歷、讀取、判斷及使用php_strip_whitespace函數(shù)刪除注釋的相關(guān)操作技巧,需要的朋友可以參考下
    2018-05-05
  • PHP動(dòng)態(tài)編譯出現(xiàn)Cannot find autoconf的解決方法

    PHP動(dòng)態(tài)編譯出現(xiàn)Cannot find autoconf的解決方法

    這篇文章主要介紹了PHP動(dòng)態(tài)編譯出現(xiàn)Cannot find autoconf的解決方法,是PHP程序設(shè)計(jì)中經(jīng)常會(huì)遇到的問題,需要的朋友可以參考下
    2014-11-11
  • php郵件發(fā)送的兩種方式

    php郵件發(fā)送的兩種方式

    本文就是根據(jù)php實(shí)現(xiàn)郵件發(fā)送的思路,整理下來的一篇文章,在遇到不同問題時(shí)給出的不同解決方法,感興趣的小伙伴們可以參考一下
    2015-10-10
  • php列出一個(gè)目錄下的所有文件的代碼

    php列出一個(gè)目錄下的所有文件的代碼

    使用php的glob函數(shù)可以列出所有符合路徑結(jié)構(gòu)的文件和目錄,以下從某cms提取出來的函數(shù)
    2012-10-10
  • php環(huán)境無法上傳文件的解決方法

    php環(huán)境無法上傳文件的解決方法

    對(duì)于dedecms 你沒有選擇上傳文件,discuz批量上傳顯示成功,但看不到圖片,ecshop商城等無法上傳問題,只要是PHP的,而且代碼本身沒有問題.以下都適用
    2014-04-04
  • PHP實(shí)現(xiàn)的一致性HASH算法示例

    PHP實(shí)現(xiàn)的一致性HASH算法示例

    這篇文章主要介紹了PHP實(shí)現(xiàn)的一致性HASH算法,結(jié)合具體實(shí)例形式分析了hash算法的具體定義與使用技巧,需要的朋友可以參考下
    2018-03-03
  • 詳解Swoole跟傳統(tǒng)的web開發(fā)的區(qū)別

    詳解Swoole跟傳統(tǒng)的web開發(fā)的區(qū)別

    Swoole高效跟傳統(tǒng)的web開發(fā)有什么區(qū)別,除了傳統(tǒng)的LAMP/LNMP同步開發(fā)模式,swoole的異步開發(fā)模式是怎么樣的。本文帶著大家來詳細(xì)介紹一下。
    2021-05-05
  • php格式化json函數(shù)示例代碼

    php格式化json函數(shù)示例代碼

    這篇文章主要介紹了php格式化json函數(shù),結(jié)合實(shí)例形式分析了php使用自定義函數(shù)實(shí)現(xiàn)json格式化的方法,涉及php數(shù)組轉(zhuǎn)json、流程控制及字符串操作等技巧,需要的朋友可以參考下
    2016-05-05
  • 總結(jié)的一些PHP開發(fā)中的tips(必看篇)

    總結(jié)的一些PHP開發(fā)中的tips(必看篇)

    下面小編就為大家?guī)硪黄偨Y(jié)的一些PHP開發(fā)中的tips(必看篇)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-03-03

最新評(píng)論