<script src="http://all.vic.sina.com.cn/asianonair/js/jquery.js"></script>
<iframe id="upload_target" name="upload_target" style="display:none"></iframe>
<form action="upload.php" id="f1" method="post" target="upload_target" enctype="multipart/form-data">
<input type="file" name="file">
<input type="button" name="submit1" value="submit1" >
</form>
<script>
$('[name=submit1]').click(function(){
$('form').submit();
});
</script>
Jquery.js 是1.5的
顺便提到一点
Jquery 提交表单死活提交不上去原因
表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, or method,是、会产生冲突。名称冲突可能会导致混乱的失败。对于一个完整的规则列表,并检查这些问题标记
upload.php
<?php
var_dump($_FILES);
echo "<script>alert('11');</script>";
?>上传成功,js处理就ok了。
关键原理还是在让表单提交到iframe里处理。
本文介绍了一种利用jQuery简化文件上传流程的方法。通过将表单提交到iframe中处理,可以实现更为灵活的文件上传功能。文章还提到了避免使用表单属性作为name或id的重要性,以防止潜在的冲突。
1180

被折叠的 条评论
为什么被折叠?



