Home >Backend Development >PHP Tutorial >Implementation code for php iframe upload files without refreshing

Implementation code for php iframe upload files without refreshing

WBOY
WBOYOriginal
2016-07-25 09:00:14871browse
You can upload files without refreshing the page. Friends who are studying this can use it as a reference.

For information about iframe, please refer to: Detailed explanation of html iframe tag object. The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="all" />
<title>Iframe无刷新上传</title>
<link rel="stylesheet" type="text/css" href="template/style.css" />
</head>
<body onload='iframe1.window.location="show_image.php"'>
<div id="header">AJAX无刷新上传演示</div>
<div id="des">
只允许上传格式为jpg,gif,png的图片,大小不超过1000K,上传后的图片会放在临时文件夹<br />
浏览器必须支持JavaScript和没有屏蔽Iframe,不然将看不到效果
</div>
<div id="mainform">
<form action="upload.php" method="post" enctype="multipart/form-data" name="upload_img" target="iframe1">
选择要上传的图片:<input type="file" name="image"><br />
<input type="submit" value="上传图片">
</form>
</div>
<div id="message" style="display:none" onclick="this.style.display='none'"></div>
<table id="maintable">
<tr>
<td colspan="2" id="title">临时文件夹中的全部图片</td>
</tr>
<tr>
<td>
<form method="post" name="delimage" action="del.php" target="iframe1">
[删除所有图片]
</form>
</td>
<td>
<form method="post" name="showimage" action="show_image.php" target="iframe1">
[刷新所有图片]
</form>
</td>
</tr>
<tr>
<td colspan="2"><div id="show_image"></div></td>
</tr>
</table>
<br>
<iframe name="iframe1" width="0" height="0" scrolling="no"></iframe>
</body>
</html>
The PHP upload method without refresh is most often implemented in combination with Ajax. Here is a reference example for you: Example of PHP Ajax uploading images without refresh. If you don’t know much about iframe refresh, I suggest you read: iframe refresh method.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn