html端:
<form action="/index.php?user&q=code/raise/upfile" id="photo_form" name="photo_form"
encType="multipart/form-data" method="post" target="hidden_frame"> //好比新窗口_blank 旧(父)窗口就不会刷新
<input type="file" id="zcfile" name="zcfile">
<INPUT type="submit" value="上传文件">
<div id="msg"></div>
<iframe name=‘hidden_frame‘ id="hidden_frame" style=‘display:none‘></iframe>
</form>
{literal}
<script type="text/javascript">
function callback(msg) {
var img = "<img src=‘"+msg+"‘>";
$("#msg").html(img)
}
</script>
{/literal}
php端:
if($_U[‘query_type‘] == "upfile"){
$name[‘file‘] = "zcfile";
$pic_result = $upload->upfile($name);
echo "<script>parent.callback(‘".$pic_result[‘filename‘]."‘)</script>"; exit; //回调函数 是旧(父)窗口的函数 所以是parent.callback
}