video_poster.php
<?php
/*
'-##########################################-|
'|    程序设计:(疯子)                |      |
'|    Email:[email protected]              |
'|    结合自己以前做的上传和生成缩略和改编一个
'|    老前辈的生成图片水印做成这个                |
'|    上传+生成缩略图+生成文字水印和图片水印      |
'|    可以直接引用                            |
'-##########################################-|
*/
//审明图片文件夹
$objupath=$_REQUEST['objuppath'];
$objtext=$_REQUEST['objtext'];
$bigfolder="img";
$smallfolder="smallimg";
//审明文件夹名称 以年月日来建议文件夹
$fdate=date("Ymd");
//echo $fdate;
//审明文件名称。以年月日时分秒命名
$fname=date("YmdHis");
$bigname="0724e_com_".$fname;
$smallname="0724e_com_".$fname."_s";//echo $fname."<br/>".$bigname."<br/>".$smallname;
//确定大小文件夹的名称和路经
$bigaddrname=$bigfolder."/".$fdate."/".$bigname;
$smalladdrname=$smallfolder."/".$fdate."/".$smallname;
//审明小图片的高度和宽度
$RESIZEWIDTH=180; 
$RESIZEHEIGHT=150;
//充许上传的文件扩展名
$exit_name=array(".jpg",".gif",".png");
if (isset($_POST['Submit'])){
//上传部分----------------------------
//定议上传名称和上传错误
$upfile=$_FILES['image']['name'];
$uperror=$_FILES['image']['error'];
//最简表单验证switch ($uperror) {
  case 1:
      die("<div align=\"center\">上传真过PHP设置充许的最大值<a href=\"javascript:history.back();\">点击返回</a></div>");
  break;
  case 2:
  die("<div align=\"center\">上传超过了表单充许的最大值<a href=\"javascript:history.back();\">点击返回</a></div>");
  break; 
  case 3:
  die("<div align=\"center\">文件只有部分被上传了<a href=\"javascript:history.back();\">点击返回</a></div>");
    break;
  case 4:
  die("<div align=\"center\">文件不有被上传<a href=\"javascript:history.back();\">点击返回</a></div>");
    break;
}//检测扩展是否是充许上传的文件类型
//取得文件扩展名
$exname=strrchr($upfile,".");
//判断取得扩展名是否在要求的扩展名内
if(!in_array($exname,$exit_name))
die("<div align=\"center\">文件扩展名不对。只允许上传jpg gif png的图片<a href=\"javascript:history.back();\">点击返回</a></div>");//检测存放图片的目录和子目录是否存在,如果不存在则建目录和子目录,并给目录最大权限777 对LINUX或unix对WINDOWS没必要
//大图
if (!file_exists($bigfolder)){
  mkdir($bigfolder,0777);
  mkdir($bigfolder."/".$fdate,0777);
}else{
  if (!file_exists($bigfolder."/".$fdate)){
  mkdir($bigfolder."/".$fdate,0777);
  }
}
//缩略图
if (!file_exists($smallfolder)){
  mkdir($smallfolder,0777);
  mkdir($smallfolder."/".$fdate,0777); 
}else{
  if (!file_exists($smallfolder."/".$fdate)){
  mkdir($smallfolder."/".$fdate,0777); 
  }
}
//创建目录结束//得到临时上传的文件
$upfiletmp=$_FILES['image']['tmp_name'];//判断临时文件是否存在
if ($uperror==6)
die("<div align=\"center\">找不到临时上传文件,上传失败<a href=\"javascript:history.back();\">点击返回</a></div>");
//存在则移动完在上传
$goodupfile=@move_uploaded_file($upfiletmp,$bigaddrname.$exname);
if (!$goodupfile){
die("<div align=\"center\">上传图片失败<a href=\"javascript:history.back();\">点击返回</a></div>");
}else{ 
    //imageWaterMark($bigaddrname.$exname,5,$imgaddr); 
//结束水印部分===================================
    //缩略图部分------------------------------------------------------------
//判断缩略图大小函数-----
    function ResizeImage($im,$maxwidth,$maxheight,$name){ 
    $width = imagesx($im); 
    $height = imagesy($im); 
    if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){ 
        if($maxwidth && $width > $maxwidth){ 
            $widthratio = $maxwidth/$width; 
            $RESIZEWIDTH=true; 
        } 
        if($maxheight && $height > $maxheight){ 
            $heightratio = $maxheight/$height; 
            $RESIZEHEIGHT=true; 
        } 
        if($RESIZEWIDTH && $RESIZEHEIGHT){ 
            if($widthratio < $heightratio){ 
                $ratio = $widthratio; 
            }else{ 
                $ratio = $heightratio; 
            } 
        }elseif($RESIZEWIDTH){ 
            $ratio = $widthratio; 
        }elseif($RESIZEHEIGHT){ 
            $ratio = $heightratio; 
        } 
        $newwidth = $width * $ratio; 
        $newheight = $height * $ratio; 
        if(function_exists("imagecopyresampled")){ 
              $newim = imagecreatetruecolor($newwidth, $newheight); 
              imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
        }else{ 
            $newim = imagecreate($newwidth, $newheight); 
              imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
        } 
        ImageJpeg ($newim,$smalladdrname.$name.".jpg"); 
        ImageDestroy ($newim); 
    }else{ 
        ImageJpeg ($im,$smalladdrname.$name.".jpg"); 
    } 
    } 
    //生成部分
    if($_FILES['image']['size']){ 
    if($_FILES['image']['type'] == "image/pjpeg"){ 
        $im = imagecreatefromjpeg($bigaddrname.$exname); 
    }elseif($_FILES['image']['type'] == "image/x-png"){ 
        $im = imagecreatefrompng($bigaddrname.$exname); 
    }elseif($_FILES['image']['type'] == "image/gif"){ 
        $im = imagecreatefromgif($bigaddrname.$exname); 
    } 
    if($im){ 
        if(file_exists($smalladdrname.".jpg")){ 
            unlink($smalladdrname.".jpg"); 
        } 
        ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$smalladdrname); 
        ImageDestroy ($im); 
    } 
    }
echo "<script> parent.document.getElementById('.$objtext.').value='".$smallname."'; </script>" ;
    echo "<div align='center'><a href='javascript:window.history.back()'>上传成功</a></div>";
}
//缩略图结束----------------------------------------------------- 
  
}
?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <input type="file" name="image" />
  <input type="hidden" name="MAX_FILE_SIZE" value="<?=1024*100?>">
  <input type="submit" name="Submit" value="上传图片" />
</form>
2.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="32%"><input name="pic_small" type="text" id="pic_smalls" size="50" maxlength="50" /></td>
    <td width="68%"><iframe id="UploadFiles" src="video_poster.php?objtext=pic_smalls" frameborder="0" scrolling="No" width="350" height="35"></iframe></td>
  </tr>
</table>
</body>
</html>
请问高手,怎么才能把上传好的路径给2.php中的<input name="pic_small" type="text" id="pic_smalls" size="50" maxlength="50" />文本框呢