<!DOCTYPE HTML>
<html lang="ru-RU">
<head>
<title>
</title>
<meta charset="UTF-8">
<style type="text/css">
iframe,input,button,li{
height:30px;
}
</style>
</head>
<body>
<div id='attachment' > </div>
<ul id="toolsbar">
<li id="uploadFile">
<div >
<iframe src="upload/frame.html" frameborder="1" id="uploadfileFrame" scrolling="no"></iframe>
</div>
</li>
</ul>
<hr>
<input id='msg' />
<button id='send' > SEND </button>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
var Uploader={
hasFileReady:false,
uploadMsg:'',
filename:'xx.jpg',
fireUpload: function(event) {
var fileframe = $("uploadfileFrame").contentWindow.document.getElementById("Button1");
fileframe.click();
},
startUpload: function(filename) {
$("toolsbar").style.display = "none";
$("attachment").innerHTML+="<li><b>"+filename+" </b> X</li> "
}
};
document.getElementById('send').addEventListener('click',function(){
Uploader.fireUpload();
})
</script>
</body>
</html>
upload/frame.html
<html>
<head>
<script type="text/javascript">
function fileChange(input){
parent.Uploader.startUpload(input.files[0].name);
}
function CheckUpload(){
alert('CheckUpload reutrn true;');
return true;
}
function checkSubmit(){
alert('checkSubmit return true');
return true;
}
</script>
</head>
<body>
<form action="/upload.php" method="post" onsubmit="return checkSubmit();"
enctype="multipart/form-data">
<input type="file" name="file" id="file" onchange="fileChange(this);" />
<br />
<input type="submit" name="submit" id="Button1" value="Submit" onclick= "return CheckUpload();" />
</form>
</body>
</html>
upload.php
<?php
print_r($_FILES);
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。