图片修改 网站如何修改图片啊,我自己做的网站修改不了图片,希望各位帮帮忙!谢谢,要代码的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你们帮我看哈我找到的代码对不对:if(isset($_REQUEST['submit'])){ $sql="update anli set atitle='".$atitle1."',atext='".$atext1."' where aid='".$id1."'"; $result=$obj->exec($sql); if($result){ if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ //判断图片临时名存是否存在 $upfile=$_FILES["upfile"]; //获得图片的信息数组 $tmp_name=$upfile["tmp_name"]; //获得临时文件名 $name=$tupian1; //获得图片的名字 $type=$upfile["type"]; //获得图片的类型 $error=$upfile["error"]; //图片错误信息成功上传时值为0 switch($type){ //限制图片的类型 case 'image/pjpeg' : $ok=true; break; case 'image/jpeg' : $ok=true; break; case 'image/gif' : $ok=true; break; case 'image/png' : $ok=true; break; } if($ok && $error=='0'){ move_uploaded_file($tmp_name,'../images/'.$name);//移动图片位置,并为其命名 } } $stradd="document.location.href=('xmal.php');"; echo "<script language=javascript>alert('修改成功!');".$stradd."</script>"; exit; } } $name=$tupian1; //获得图片的名字中的 $tupian1 是在哪里赋值的?如果是提交过来的,应写作 $_REQUEST['tupian1'] <? require_once('mssql.php'); $atitle=$_GET["atitle"]; $tupian=$_GET["aphoto"]; $atext=$_GET["atext"]; $aid=$_GET["aid"]; $atitle1=$_POST["atitle"]; $tupian1=$_POST["tupian1"]; $atext1=$_POST["atext"]; $id1=$_POST["id2"]; if(isset($_REQUEST['submit'])){ $sql="update anli set atitle='".$atitle1."',atext='".$atext1."' where aid='".$id1."'"; $result=$obj->exec($sql); if($result){ if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ //判断图片临时名存是否存在 $upfile=$_FILES["upfile"]; //获得图片的信息数组 $tmp_name=$upfile["tmp_name"]; //获得临时文件名 $name=$tupian1; //获得图片的名字 $type=$upfile["type"]; //获得图片的类型 $error=$upfile["error"]; //图片错误信息成功上传时值为0 switch($type){ //限制图片的类型 case 'image/pjpeg' : $ok=true; break; case 'image/jpeg' : $ok=true; break; case 'image/gif' : $ok=true; break; case 'image/png' : $ok=true; break; } if($ok && $error=='0'){ move_uploaded_file($tmp_name,'../images/'.$name);//移动图片位置,并为其命名 } } $stradd="document.location.href=('xmal.php');"; echo "<script language=javascript>alert('修改成功!');".$stradd."</script>"; exit; } } ?><form action="xmal_update.php" method="post" enctype="multipart/form-data">标题:<input type="text" name="atitle" value="<?=$atitle;?>"/><br />图片:<input type="file" name="upfile" id="upfile" /><input type="hidden" name="id2" value="<?=$aid;?>"/><input type="hidden" name="tupian1" value="<?=$tupian;?>"/><br />内容:<textarea cols="65" rows="12" name="atext"><?=$atext;?></textarea><input type="submit" name="submit" value="修改" style="height: 30px; width: 100px; cursor:pointer;"/></form> //上传的时候选择一张jpg图片.然后修改下面的代码.不管页面提示什么错误,先看看这个目录有没有test.jpgmove_uploaded_file($tmp_name,'../images/'.$name);//换成move_uploaded_file($tmp_name, 'test.jpg'); 有啊,我用我的这个代码修改比如我修改11.jpg这张图片,他都会生成11.jpg一个文件可是打不开这个文件,原来的图片11.jpg也在而且还显示一样。 网址缩短程序源码,求助帮忙修复 昏倒,原来调用web service还有更简单的方法 微软不屑抄袭火狐吗? 关于安全的会员登陆和保持登陆状态的办法,欢迎讨论 本机上正常,服务器上网站不能用!!!急啊!!!! 超难的CSS控件问题...高手请进!!!! 图片版块翻页效果。。。 Google是用MYSQL作为后台数据库? 关于MYSQL在PHP中编程的问题!控制数据库中的数据只能一个人访问? 学php需要什么基础? 【求助】关于php变量的变量的问题 请教高手 关于Smarty的问题!!!
if(isset($_REQUEST['submit'])){
$sql="update anli set atitle='".$atitle1."',atext='".$atext1."' where aid='".$id1."'";
$result=$obj->exec($sql);
if($result){
if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ //判断图片临时名存是否存在
$upfile=$_FILES["upfile"]; //获得图片的信息数组
$tmp_name=$upfile["tmp_name"]; //获得临时文件名
$name=$tupian1; //获得图片的名字
$type=$upfile["type"]; //获得图片的类型
$error=$upfile["error"]; //图片错误信息成功上传时值为0
switch($type){ //限制图片的类型
case 'image/pjpeg' : $ok=true;
break;
case 'image/jpeg' : $ok=true;
break;
case 'image/gif' : $ok=true;
break;
case 'image/png' : $ok=true;
break;
}
if($ok && $error=='0'){
move_uploaded_file($tmp_name,'../images/'.$name);//移动图片位置,并为其命名
}
}
$stradd="document.location.href=('xmal.php');";
echo "<script language=javascript>alert('修改成功!');".$stradd."</script>";
exit;
}
}
中的 $tupian1 是在哪里赋值的?
如果是提交过来的,应写作 $_REQUEST['tupian1']
require_once('mssql.php');
$atitle=$_GET["atitle"];
$tupian=$_GET["aphoto"];
$atext=$_GET["atext"];
$aid=$_GET["aid"];
$atitle1=$_POST["atitle"];
$tupian1=$_POST["tupian1"];
$atext1=$_POST["atext"];
$id1=$_POST["id2"];
if(isset($_REQUEST['submit'])){
$sql="update anli set atitle='".$atitle1."',atext='".$atext1."' where aid='".$id1."'";
$result=$obj->exec($sql);
if($result){
if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ //判断图片临时名存是否存在
$upfile=$_FILES["upfile"]; //获得图片的信息数组
$tmp_name=$upfile["tmp_name"]; //获得临时文件名
$name=$tupian1; //获得图片的名字
$type=$upfile["type"]; //获得图片的类型
$error=$upfile["error"]; //图片错误信息成功上传时值为0
switch($type){ //限制图片的类型
case 'image/pjpeg' : $ok=true;
break;
case 'image/jpeg' : $ok=true;
break;
case 'image/gif' : $ok=true;
break;
case 'image/png' : $ok=true;
break;
}
if($ok && $error=='0'){
move_uploaded_file($tmp_name,'../images/'.$name);//移动图片位置,并为其命名
}
}
$stradd="document.location.href=('xmal.php');";
echo "<script language=javascript>alert('修改成功!');".$stradd."</script>";
exit;
}
}
?>
<form action="xmal_update.php" method="post" enctype="multipart/form-data">
标题:<input type="text" name="atitle" value="<?=$atitle;?>"/><br />
图片:<input type="file" name="upfile" id="upfile" />
<input type="hidden" name="id2" value="<?=$aid;?>"/>
<input type="hidden" name="tupian1" value="<?=$tupian;?>"/><br />
内容:<textarea cols="65" rows="12" name="atext"><?=$atext;?></textarea>
<input type="submit" name="submit" value="修改" style="height: 30px; width: 100px; cursor:pointer;"/>
</form>
//上传的时候选择一张jpg图片.然后修改下面的代码.不管页面提示什么错误,先看看这个目录有没有test.jpgmove_uploaded_file($tmp_name,'../images/'.$name);
//换成
move_uploaded_file($tmp_name, 'test.jpg');