iframe仿ajax图片上传

1.前台页面:

iframe_upload.html

<html>    
<body>    
   
<form action="upload.php" id="form1" name="form1" encType="multipart/form-data" method="post" target="hidden_frame" >    
     <input type="file" id="file" name="file" style="450">    
     <INPUT type="submit" value="上传文件"><span><img src="" id="msg"></span>    
</form>               
<iframe name='hidden_frame' id="hidden_frame" style="display:none;"></iframe>
<span class="hilite2"></span>    
</body>    
</html>    
   
<script type="text/javascript">    
function callback(msg)    
{    
     document.getElementById("msg").src = msg;    
}    
</script>   

2.php处理端

upload.php

<?php
    //print_r($_FILES);
  //处理过程省略,主要是展示回调js函数进行处理
$pic = 'images/100.jpg'; echo "<script>parent.callback('".$pic."')</script>"; ?>
时不我待,不负韶华!立刻行动!不吃学习的苦就会吃生活的苦!
原文地址:https://www.cnblogs.com/zrp2013/p/3471595.html