php jquery multiple file upload_PHP tutorial
Release: 2016-07-13 17:18:48
Original
1142 people have browsed it
php jquery 多文件上传
演示
XML/HTML Code
-
Upload
-
-
- <script> </li>
<li class="alt"> </li>
<li>$(document).ready(function() </li>
<li class="alt">{ </li>
<li> </li>
<li class="alt">var settings = { </li>
<li> url: "upload.php", </li>
<li class="alt"> method: "POST", </li>
<li> allowedTypes:"jpg,png,gif,doc,pdf,zip", </li>
<li class="alt"> fileName: "myfile", </li>
<li> multiple: true, </li>
<li class="alt"> onSuccess:function(files,data,xhr) </li>
<li> { </li>
<li class="alt"> $("#status").html("<font color="green">Upload is success</font>"); </li>
<li> </li>
<li class="alt"> }, </li>
<li> onError: function(files,status,errMsg) </li>
<li class="alt"> { </li>
<li> $("#status").html("<font color="red">Upload is Failed</font>"); </li>
<li class="alt"> } </li>
<li>} </li>
<li class="alt">$("#mulitplefileuploader").uploadFile(settings); </li>
<li> </li>
<li class="alt">}); </li>
<li></script>
upload.php
PHP Code
-
//If directory doesnot exists create it.
- $output_dir = "../upload";
-
- if(isset($_FILES["myfile"]))
- {
- $ret = array();
-
- $error =$_FILES["myfile"]["error"];
- {
-
- if(!is_array($_FILES["myfile"]['name'])) //single file
- {
- $fileName = $_FILES["myfile"]["name"];
- move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir. $_FILES["myfile"]["name"]);
- //echo "
Error: ".$_FILES["myfile"]["error"];
-
- $ret[$fileName]= $output_dir.$fileName;
- }
- else
- {
- $fileCount = count($_FILES["myfile"]['name']);
- for($i=0; $i {
- $fileName = $_FILES["myfile"]["name"][$i];
- $ret[$fileName]= $output_dir.$fileName;
- move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName );
- }
-
- }
- }
- echo json_encode($ret);
-
- }
-
- ?>
原文地址:http://www.freejs.net/article_biaodan_116.html
http://www.bkjia.com/PHPjc/621610.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621610.htmlTechArticlephp jquery 多文件上传 演示 XML/HTML Code Upload script $(document).ready(function() { var settings = { url: "upload.php", method: "POST", allowedTypes:"jpg,png,gif,doc,pdf,z...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31