iframe upload:
<iframe frameborder=0 style="width:350px;height:60px;padding:0px;border:0px;background:#fff" src="?act=upload"></iframe>
上传接口iframe回调主窗口的函数,有点类似与ajax:
if($_GET['act']=='upload'){
if($_POST['upload']=='upload'){
$uploaddir ='upload/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "<script>alert('文件上传失败!');</script>";exit;
}else{
$f1="<img src='{$uploadfile}' id='ImageDrag' class='imagePhoto' >";
$f2="<img src='{$uploadfile}' id='ImageIcon' class='imagePhoto'>";
echo '<script language="javascript">parent.$("#ImageDragContainer").html("'.$f1.'");parent.$("#IconContainer").html("'.$f2.'");parent.$("#bigImage").val("'.$uploadfile.'");parent.go();parent.move();</script>';
}
}
接受上传文件,Iframe提交后用js来修改下面的html中的img:
<div id="ImageDragContainer">
<img src='image/dd.JPG' id='ImageDrag' class='imagePhoto'>
</div>
<div id="IconContainer">
<img src='image/dd.JPG' id='ImageIcon' class='imagePhoto'>
</div>
$iconElement = $("#ImageIcon");
$imagedrag = $("#ImageDrag");
alert($iconElement.attr('src'));
alert($imagedrag.attr('src'));
<iframe frameborder=0 style="width:350px;height:60px;padding:0px;border:0px;background:#fff" src="?act=upload"></iframe>
上传接口iframe回调主窗口的函数,有点类似与ajax:
if($_GET['act']=='upload'){
if($_POST['upload']=='upload'){
$uploaddir ='upload/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "<script>alert('文件上传失败!');</script>";exit;
}else{
$f1="<img src='{$uploadfile}' id='ImageDrag' class='imagePhoto' >";
$f2="<img src='{$uploadfile}' id='ImageIcon' class='imagePhoto'>";
echo '<script language="javascript">parent.$("#ImageDragContainer").html("'.$f1.'");parent.$("#IconContainer").html("'.$f2.'");parent.$("#bigImage").val("'.$uploadfile.'");parent.go();parent.move();</script>';
}
}
接受上传文件,Iframe提交后用js来修改下面的html中的img:
<div id="ImageDragContainer">
<img src='image/dd.JPG' id='ImageDrag' class='imagePhoto'>
</div>
<div id="IconContainer">
<img src='image/dd.JPG' id='ImageIcon' class='imagePhoto'>
</div>
$iconElement = $("#ImageIcon");
$imagedrag = $("#ImageDrag");
alert($iconElement.attr('src'));
alert($imagedrag.attr('src'));
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2133/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表