mini ajax 上传

来源:互联网 发布:java显示 隐式 编辑:程序博客网 时间:2024/04/28 02:32

本例用了很多的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

原创粉丝点击