绿竹居
注册会员

UID 75446
精华
0
积分 182
帖子 158
金钱 182 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-6-23 来自 湖北*钟祥
状态 离线
|
图片地址的传递???
现在有一个产品页。中有图片项。中点击上传图片后就会弹出一个窗口,就是上传图片的页面。。在这个页执行图片的上传。。。上传成功后我想把这个图片的路经打印到原来的产品页上同进关闭本身。这个代码应怎么写呢????
在同一个页面打印
echo "<script>parent.upfileform.big_image.value+='".$upnewname_addr."'</script>" ;
关闭本身会。。现在要打印这个值
大家帮帮忙呀~~~~~~~~~~
就是这样的
第一个页
<form name="form1" method="post" action="">
<input type="text" name="upname">
<a href="up_smallimage.php">上传
</a>
</form>
第二个页
<?php
session_start();
date_default_timezone_set('PRC');
if (isset($_POST['Submit'])){
$upload_dir="../pro_image/";
$upfilename=$_FILES['upfile']['name'];
$uperror=$_FILES['upfile']['error'];
switch($uperror){
case 1:
die("<div align='center'><a href='javascript:window.history.back()'>上传文件过大SYS</a></div>");
break;
case 2:
die("<div align='center'><a href='javascript:window.history.back()'>上传文件过大FORM</a></div>");
break;
case 4:
die("<div align='center'><a href='javascript:window.history.back()'>文件没有被上传</a></div>");
break;
}
$newfilename=strrchr($upfilename,".");
$ext_name=array('.jpg','.gif','.png');
if (!in_array($newfilename,$ext_name)){
die("<div align='center'><a href='javascript:window.history.back()'>上传文件类型不对:可传jpg、gif、png</a></div>");
}
$ext_file_name=$_FILES['upfile']['tmp_name'];
$upnewfile="zjun_".date("YmdHis");
$upnewname_addr=$upload_dir.$upnewfile.$newfilename;
if (move_uploaded_file($ext_file_name,$upnewname_addr)){
echo "<div align='center'><a href='javascript:window.history.back()'>上传成功</a></div>";
echo "<script>parent.form1.big_image.value+='".$upnewname_addr."'</script>" ;
}
else{
echo "<div align='center'><a href='javascript:window.history.back()'>上传失败</a></div>";
}
}
else
{
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>上传图片</title>
<link href="../admin/admin_css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="340" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td colspan="2" class="bt_bg"><div align="center">上传产品图片</div></td>
</tr>
<tr>
<td width="221"><div align="center">
<input name="max_file_size" type="hidden" id="max_file_size" value="<?=1024*1024*0.05?>">
<input name="upfile" type="file" id="upfile" />
</div></td>
<td width="80"><div align="center">
<input type="submit" name="Submit" value="提交上传" />
</div></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
想把第二个页的$upnewname_addr 的值传到第一个页的upname这个INPUT中。那位帮帮忙呀。。
|
|