网站如何修改图片啊,我自己做的网站修改不了图片,希望各位帮帮忙!谢谢,要代码的。
解决方案 »
- php 中如何定义这样一个对象
- PHP 编码转换软件
- tab面板 加载会显示a标签那种链接样式 过一秒后显示正常?
- PHP可以实现ASP中Server.Transfer方法吗?
- 升级了php后,我为什么接收不到上一页传送上来的值?谢谢。
- ???关于php的安装问题
- 完全用PHP实现虚拟二级域名http://name@domain/的问题
- 请各位大侠指教在FF下,如何提交表单啊?
- php字符变量 异或 疑问,请解决
- 网站访问报错 PHP Parse error: syntax error, unexpected '[' in E:\WWW\weixin\security\
- 【求助】关于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');