PHP使用Iframe无刷新上传解决代码

手册/FAQ (504) 2016-04-11 15:00:07

<!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"> 
<a href="#" onclick='javascript:document.delimage.submit();'>[删除所有图片]</a> 
</form> 
</td> 
<td> 
<form method="post" name="showimage" action="show_image.php" target="iframe1"> 
<a href="#" onclick="javascript:document.showimage.submit();">[刷新所有图片]</a> 
</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 END