-
-
Upload
-
- <script> </li>
<li>$(document).ready(function() </li>
<li>{</li>
<li>var settings = { </li>
<li> url: "upload.php", </li>
<li> method: "POST", </li>
<li> allowedTypes:"jpg,png,gif,doc,pdf,zip", </li>
<li> fileName: "myfile", </li>
<li> multiple: true, </li>
<li> onSuccess:function(files,data,xhr) </li>
<li> { </li>
<li> $("#status").html("<font color='green'>Upload is success</font>"); </p></li>
<li><p> }, </li>
<li> onError: function(files,status,errMsg) </li>
<li> { </li>
<li> $("#status").html("<font color='red'>Upload is Failed</font>"); </li>
<li> } </li>
<li>} </li>
<li>$("#mulitplefileuploader").uploadFile(settings); </p></li>
<li><p>}); </li>
<li></script>
-
复制代码
2,php多文件上传代码 upload.php
-
-
- //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 < $fileCount; $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);
- }
- ?>
-
复制代码
3,效果图,如下:
>>> 您可能感兴趣的文章:
PHP图片上传类(多文件上传、缩略图、水印)
PHP上传多文件、多图片的示例代码
php上传多文件与多图片的实例代码
php多文件上传的简单示例分析
php 普通表单多文件上传的例子
php 多文件上传的简单例子(入门)
php多文件上传的三种方法
|