作者:大眼妹886 | 来源:互联网 | 2017-05-13 02:31
phpjquery多文件上传简单实例。复制代码代码如下:divUploaddivdivdivscript$(document).ready(function(){varsettings{url:upload.php,method:POST,all
代码如下:
Upload
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);
}
?>
http://www.bkjia.com/PHPjc/621674.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621674.htmlTechArticle 代码如下: p id="mulitplefileuploader"Upload/p p id="status"/p script $(document).ready(function() { var settings = { url: "upload.php", method: "POST", all...