mini ajax 上传

本例用了很多的js文件

到演示页面可以查看源码或者存储

mini ajax 上传

 

XML/HTML Code
  1. <form id="upload" method="post" action="upload.php" enctype="multipart/form-data">  
  2.             <div id="drop">  
  3.                 Drop Here  
  4.   
  5.                 <a>Browse</a>  
  6.                 <input type="file" name="upl" multiple />  
  7.             </div>  
  8.   
  9.             <ul>  
  10.                 <!-- The file uploads will be shown here -->  
  11.             </ul>  
  12.   
  13.         </form>  

 

PHP Code
  1. <?php  
  2.   
  3. // A list of permitted file extensions  
  4. $allowed = array('png''jpg''gif','zip');  
  5.   
  6. if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){  
  7.   
  8.     $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);  
  9.   
  10.     if(!in_array(strtolower($extension), $allowed)){  
  11.         echo '{"status":"error"}';  
  12.         exit;  
  13.     }  
  14.   
  15.     if(move_uploaded_file($_FILES['upl']['tmp_name'], '../upload/'.$_FILES['upl']['name'])){  
  16.         echo '{"status":"success"}';  
  17.         exit;  
  18.     }  
  19. }  
  20.   
  21. echo '{"status":"error"}';  
  22. exit;  
  23. ?>  

 


原文地址:http://www.freejs.net/article_biaodan_78.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值