pro_add.php 代码
<tr>
      <td class="td_bg" width="8%">产品图片一:</td>
      <td class="td_bg" width="21%" height="26"><input type="text" name="pic_1" id="pic_1" value="" size="30" /></td>
      <td class="td_bg" width="71%" height="26"><iframe border=0 frameborder=0 framespacing=0 height=22 width=600 marginheight=0 marginwidth=0  scrolling=no  src="[b]uppic.php?id=pic_1[/b]" ></iframe></td>
    </tr>
    <tr>
      <td class="td_bg" width="8%">产品图片二:</td>
      <td class="td_bg" width="21%" height="26" ><input type="text" name="pic_2" id="pic_2" value="" size="30" /></td>
      <td class="td_bg" width="71%" height="26"><iframe border=0 frameborder=0 framespacing=0 height=22 width=600 marginheight=0 marginwidth=0 scrolling=no  src="uppic.php?id=pic_2" ></iframe></td>
    </tr>
    <tr>
      <td class="td_bg" width="8%">产品图片三:</td>
      <td class="td_bg" width="21%" height="26"><input type="text" name="pic_3" id="pic_3" value="" size="30" /></td>
      <td class="td_bg" width="71%" height="26"><iframe border=0 frameborder=0 framespacing=0 height=22 width=600 marginheight=0 marginwidth=0  scrolling=no  src="[b]uppic.php?id=pic_3[b]" ></iframe></td>
    </tr>uppic.php 代码<?php$id=$_GET["id"];
//echo "id==".$id;  //首次加载时可以提到id的值
switch($_GET["action"])
{
case "up":
echo $id;   // 到这里就提不到了这是为什么upmovie($id);
break;
default:
upinput($id);
break;
}
function upinput($id){
?>
<SCRIPT language=javascript>
function elincheck()
{
var strFileName=document.formpic.strPhoto.value;
if (strFileName=="")
{
     alert("请选择要上传的文件");
    document.formpic.strPhoto.focus();
     return false;
   }
return true;
}
</SCRIPT>
<form action='uppic.php?id=<? echo $id?>&action=up' enctype="multipart/form-data" name="formpic" method="post" onSubmit="if (!elincheck()) return false;"><input name="strPhoto" type="file" id="strPhoto" size="40">
<input type="submit" name="Submit" value="上 传" class="inputbut" />
</form>
</BODY>
<?php
}function upmovie($id)
{
global $web_picdir;
$savePath=$web_picdir;
$attach_subdir = 'day_'.date('ymd');
$attach_dir = $savePath.'/'.$attach_subdir;
if(!is_dir($attach_dir))
{
@mkdir($attach_dir, 0777);
@fclose(fopen($attach_dir.'/index.htm', 'w'));
}
$str = date('YmdHis');

if($_FILES['strPhoto']['name']!='')
{
   $tmp_file=$_FILES['strPhoto']['tmp_name'];
   $file_types=explode(".",$_FILES['strPhoto']['name']);
   $file_type=$file_types[count($file_types)-1];
   
    if(strtolower($file_type)!="jpg"&strtolower($file_type)!="gif"&strtolower($file_type)!="bmp"&strtolower($file_type)!="png")
 {
        echo "<span style=\"color:red;line-height: 25px;\">格式错误请重新上传<a href=# onclick=history.go(-1);>[返回]</a></span>";
       exit;
       }
    $file_name=$str.".".$file_type;
   
    if(!copy($tmp_file,$attach_dir.'/'.$file_name))
    {
     echo "<span style=\"color:red;line-height: 25px;\">上传错误请重试!!<a href=# onclick=history.go(-1);>[返回]</a></span>";
    }
    else
    {
      $attach_dir=str_replace("../","",$attach_dir);
 
     echo "<span style=\"olor:red;line-height: 25px;\">上传成功</span><script type='text/javascript' language='javascript'> document.getElementById(\"{$id}\").value=\"".$attach_dir.'/'.$file_name."\"</script>";
 
      echo "<a href=# onclick=history.go(-1);>,若需要修改,请重新上传</a>";
    }
}
else
{
   echo "<span style=\"color:red;line-height: 25px;\">请选择需要上传的文件<a href=# onclick=history.go(-1);>[返回]</a></span>";
}}?>

解决方案 »

  1.   

    现在$id能提到值了 
    这段代码有问题
    echo "<span style=\"olor:red;line-height: 25px;\">上传成功
    </span><script type='text/javascript'>
    document.getElementById('".$id."').value=\"".$attach_dir.'/'.$file_name."\";</script>";
      

  2.   

    恭喜解决
    还有下次发代码的时候,能不能格式整理一下,用CSDN的代码高亮?
      

  3.   

    echo "<span style=\"olor:red;line-height: 25px;\">上传成功</span><script type='text/javascript'>
     document.getElementById(\"".$id."\").value=\"".$attach_dir.'/'.$file_name."\";</script>";