上传图片在原页面指定位置打开 我想实现的目的是将上传的图片在这个页面指定位置打开,然后在图上通过鼠标点击取坐标值,然后进行计算。但是上传图片之后总是在新的页面打开,我没办法进行后面的操作,求解决办法……拜托各位高手了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 能详细点么,我上传的代码是这个<?phpif ($_SERVER['REQUEST_METHOD'] == 'POST'){if (!is_uploaded_file($_FILES["upfile"][tmp_name]))//是否存在文件{echo "<font color='red'>文件不存在!</font>";exit;}$file = $_FILES["upfile"];if($max_file_size < $file["size"])//检查文件大小{echo "<font color='red'>文件太大!</font>";exit; }if(!in_array($file["type"], $uptypes))//检查文件类型{echo "<font color='red'>只能上传图像文件或Flash!</font>";exit;}if(!file_exists($destination_folder))mkdir($destination_folder);$filename=$file["tmp_name"];$image_size = getimagesize($filename);$pinfo=pathinfo($file["name"]);$ftype=$pinfo[extension];$destination = $destination_folder.time().".".$ftype;if (file_exists($destination) && $overwrite != true) { echo "<font color='red'>同名文件已经存在了!</a>"; exit; }if(!move_uploaded_file ($filename, $destination)){ echo "<font color='red'>移动文件出错!</a>"; exit; }$pinfo=pathinfo($destination);$fname=$pinfo[basename];echo " <font color=red>已经成功上传</font><br>文件名: <font color=blue>".$destination_folder.$fname."</font><br>";echo " 宽度:".$image_size[0];echo " 长度:".$image_size[1];if($water==1){$iinfo=getimagesize($destination,$iinfo);$nimage=imagecreatetruecolor($image_size[0],$image_size[1]);$white=imagecolorallocate($nimage,255,255,255);$black=imagecolorallocate($nimage,0,0,0);$red=imagecolorallocate($nimage,255,0,0);imagefill($nimage,0,0,$white); switch ($iinfo[2]){case 1:$simage =imagecreatefromgif($destination);break;case 2:$simage =imagecreatefromjpeg($destination);break;case 3:$simage =imagecreatefrompng($destination);break;case 6:$simage =imagecreatefromwbmp($destination);break;default:die("<font color='red'>不能上传此类型文件!</a>");exit;}imagecopy($nimage,$simage,0,0,0,0,$image_size[0],$image_size[1]);imagefilledrectangle($nimage,1,$image_size[1]-15,80,$image_size[1],$white);switch($watertype){case 1: //加水印字符串imagestring($nimage,2,3,$image_size[1]-15,$waterstring,$black);break;case 2: //加水印图片$simage1 =imagecreatefromgif("xplore.gif");imagecopy($nimage,$simage1,0,0,0,0,85,15);imagedestroy($simage1);break;}switch ($iinfo[2]){case 1://imagegif($nimage, $destination); imagejpeg($nimage, $destination);break;case 2:imagejpeg($nimage, $destination);break;case 3:imagepng($nimage, $destination);break;case 6:imagewbmp($nimage, $destination);//imagejpeg($nimage, $destination);break;}//覆盖原上传文件imagedestroy($nimage);imagedestroy($simage);}if($imgpreview==1){echo "<br>图片预览:<br>";echo "<a href=\"".$destination."\" target='_blank'><img src=\"".$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize);echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\" border='0'></a>";}}?>文件名是个变量,怎么在本页不改变本页其他设置的情况下在指定位置打开它呢 echo "<a href=\"".$destination."\" target='_self'>这样试试 没有反应……可是写成 echo "<a href=\"".$destination."\" target='_self'>open</a>";之后打开虽然是本页,但是除了图片其他的都没有了…… 哈哈,当然是出了图片就什么都没了;兄弟你没说清楚啊,呵呵。如此说来,需要加个层(就是容器),绝对定位,点击链接的时候什么都不做,只执行一下JS,这个JS给那个层定位到它该显示的地方;或者页面加载的时候就定位好。点链接的时候只是让它显示出来就可以了 echo "<br><span onclick=\"document.getElementById('myImg').style.display='inline'\">图片预览:</span><br>";echo "<div id=myImg style='position:absolute;left:XXpx;top:YYpx;'>"echo "<img src=\"".$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize);echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\" border='0'>";echo "</div>";XX,YY分别代表DIV左上角的坐标值我说手敲的代码,你自己斟酌一下 谁有类似淘宝掌柜热卖的图片滚动效果 邮箱、论坛之类的富文本编辑框如何实现的? 请教一下,程序员一般负责js中的哪几部分? 向iframe 传递值 在线等~! 求几个能用的java script的图片转换脚本~~~ 有没有简繁转化之类的程序,在线等~~~ 使用XMLHTTP碰到的麻烦问题 请问怎么关闭窗口 帮帮啊,各位高手 请教:javascript如何捕获方向键? Extjs tree的拖拽后排序问题 ,求教 关于求教得到层位置的问题?
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!is_uploaded_file($_FILES["upfile"][tmp_name]))
//是否存在文件
{
echo "<font color='red'>文件不存在!</font>";
exit;
}$file = $_FILES["upfile"];
if($max_file_size < $file["size"])
//检查文件大小
{
echo "<font color='red'>文件太大!</font>";
exit;
}if(!in_array($file["type"], $uptypes))
//检查文件类型
{
echo "<font color='red'>只能上传图像文件或Flash!</font>";
exit;
}if(!file_exists($destination_folder))
mkdir($destination_folder);$filename=$file["tmp_name"];
$image_size = getimagesize($filename);
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo[extension];
$destination = $destination_folder.time().".".$ftype;
if (file_exists($destination) && $overwrite != true) {
echo "<font color='red'>同名文件已经存在了!</a>";
exit;
}if(!move_uploaded_file ($filename, $destination))
{
echo "<font color='red'>移动文件出错!</a>";
exit;
}$pinfo=pathinfo($destination);
$fname=$pinfo[basename];
echo " <font color=red>已经成功上传</font><br>文件名: <font color=blue>".$destination_folder.$fname."</font><br>";
echo " 宽度:".$image_size[0];
echo " 长度:".$image_size[1];
if($water==1)
{
$iinfo=getimagesize($destination,$iinfo);
$nimage=imagecreatetruecolor($image_size[0],$image_size[1]);
$white=imagecolorallocate($nimage,255,255,255);
$black=imagecolorallocate($nimage,0,0,0);
$red=imagecolorallocate($nimage,255,0,0);
imagefill($nimage,0,0,$white); switch ($iinfo[2])
{
case 1:
$simage =imagecreatefromgif($destination);
break;
case 2:
$simage =imagecreatefromjpeg($destination);
break;
case 3:
$simage =imagecreatefrompng($destination);
break;
case 6:
$simage =imagecreatefromwbmp($destination);
break;
default:
die("<font color='red'>不能上传此类型文件!</a>");
exit;
}imagecopy($nimage,$simage,0,0,0,0,$image_size[0],$image_size[1]);
imagefilledrectangle($nimage,1,$image_size[1]-15,80,$image_size[1],$white);switch($watertype)
{
case 1: //加水印字符串
imagestring($nimage,2,3,$image_size[1]-15,$waterstring,$black);
break;
case 2: //加水印图片
$simage1 =imagecreatefromgif("xplore.gif");
imagecopy($nimage,$simage1,0,0,0,0,85,15);
imagedestroy($simage1);
break;
}switch ($iinfo[2])
{
case 1:
//imagegif($nimage, $destination);
imagejpeg($nimage, $destination);
break;
case 2:
imagejpeg($nimage, $destination);
break;
case 3:
imagepng($nimage, $destination);
break;
case 6:
imagewbmp($nimage, $destination);
//imagejpeg($nimage, $destination);
break;
}//覆盖原上传文件
imagedestroy($nimage);
imagedestroy($simage);
}if($imgpreview==1)
{
echo "<br>图片预览:<br>";
echo "<a href=\"".$destination."\" target='_blank'><img src=\"".$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize);
echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\" border='0'></a>";
}
}?>
文件名是个变量,怎么在本页不改变本页其他设置的情况下在指定位置打开它呢
这样试试
之后打开虽然是本页,但是除了图片其他的都没有了……
echo "<br><span onclick=\"document.getElementById('myImg').style.display='inline'\">图片预览:</span><br>";
echo "<div id=myImg style='position:absolute;left:XXpx;top:YYpx;'>"
echo "<img src=\"".$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize);
echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\" border='0'>";
echo "</div>";XX,YY分别代表DIV左上角的坐标值我说手敲的代码,你自己斟酌一下