教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php ajax方式提交file表单的小例子

php ajax方式提交file表单的小例子

发布时间:2017-04-02   编辑:jiaochengji.com
本文介绍下,在php编程中,以ajax方式提交file表单的简单实例,有兴趣的朋友参考学习下。

本节内容:
ajax方式提交file表单

要求实现:
不刷新提交 file 表单,通过iframe实现。

1,test.html
 

复制代码 代码示例:
<html>
<head>
<script type="text/javascript">
function test(msg){
 alert(msg);
}
</script>
</head>
<body>
<form action="test.php" enctype="multipart/form-data" method="post" target='hidden_iframe'>
 <input type="file" id="file" name="file" />
 <input type="submit" value="submit" />
</form>
<iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" ></iframe>
</body>
</html>

2,test.php
 

复制代码 代码示例:
<?php
//此处放置你的代码
echo "<script type='text/javascript'>parent.test('some messages');</script>";
?>

您可能感兴趣的文章:
php ajax方式提交file表单的小例子
php curl上传文件的简单例子
php防止表单重复提交的小例子
jsp ajax提交带文件上传的表单例子
PHP的AJAX技术实现文件异步上传
php单文件上传的实例分析
jquery下异步提交表单 异步跨域提交表单
php跨域提交form表单2种方法
thinkphp ajax提交token的方法介绍
php文件上传步骤

[关闭]
~ ~