index
<html>
<head>
<title>無刷新上傳文件</title>
<meta Content
<script type="text/javascript">
function startUpload() {
document
return true;
}
function stopUpload(rel){
var msg;
switch (rel) {
case
msg = "上傳成功";
break;
case
msg = "上傳的文件超過限制";
break;
case
msg = "只能上傳圖片文件";
break;
default:
msg = "上傳文件失敗";
}
document
}
</script>
</head>
<body>
<div style="text
<div id="processing"></div>
<form action="upload
<input type="hidden" name="MAX_FILE_SIZE" value="
<input type="file" name="myfile" />
<input type="submit" name="sub" value="upload" />
</form>
<iframe style="width:
</div>
</body>
</html>
upload
<?php
sleep(
$fileTypes = array(
$result = null;
$uploadDir =
$maxSize =
if ($_SERVER[
$myfile = $_FILES[
$myfileType = substr($myfile[
if ($myfile[
$result =
} else if (!in_array($myfileType
$result =
} elseif (is_uploaded_file($myfile[
$toFile = $uploadDir
if (@move_uploaded_file($myfile[
$result =
} else {
$result =
}
} else {
$result =
}
}
?>
<script type="text/javascript">
window
From:http://tw.wingwit.com/Article/program/PHP/201311/20855.html