如何在不更改图像字段的情况下更新记录。 [英] how to update the record without change the image field.

查看:60
本文介绍了如何在不更改图像字段的情况下更新记录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我更改图像,它会将值存储到数据库中。如果不给它不保存编辑的记录。现在我想更新记录而不更改图像,我也想通过仅更改图像来更新记录。我的代码如下所示

if i change the image it store the values into data base. if won't give it does not save the edited record. Now I want to update record without change image and also i want to update records by only changing the image. my code as follow

<?php 
	if(isset($_POST['submit']))
	{
		$var=$_GET['a_id'];
		$file=$_SERVER['DOCUMENT_ROOT'].'myproject/cp/image/'.$img['a_image'];
		unlink($file);
		$var1=$_POST['Title'];
		$var2=$_POST['Description'];
		$image=$_FILES['imageupload']['name'];
		$root=$_SERVER['DOCUMENT_ROOT'].'/myproject/cp/image/'; 
		$file_exts = array("jpg", "bmp", "jpeg", "gif", "png");
		$expo=explode(".", $_FILES["imageupload"]["name"]); 
		$upload_exts = end($expo);
			if ((($_FILES["imageupload"]["type"] == "image/gif")|| ($_FILES["imageupload"]["type"] == "image/jpeg")|| ($_FILES["imageupload"]["type"] == "image/png")|| ($_FILES["imageupload"]["type"] == "image/jpg"))&& ($_FILES["imageupload"]["size"] < 2000000)&& in_array($upload_exts,$file_exts))
			{
					if ($_FILES["imageupload"]["error"] > 0)
					{
						echo "Return Code: " . $_FILES["imageupload"]["error"] . "<br>";
					}
					else
					{
						$image= rand(0,9999).'.'.$upload_exts;
						move_uploaded_file($_FILES["imageupload"]["tmp_name"],$root.$image);
						$sql=mysql_query("UPDATE about SET a_title='".$var1."',a_description='".$var2."',a_image='".$image."' WHERE a_id='".$var."'") or die(mysql_error());
						echo "<meta http-equiv=refresh content=\"0; URL=about.php\">";
					}
			}		
	}
?>

请帮我来过来这个问题。

please help me to over come from this problem.

推荐答案

_POST [' submit']))
{
_POST['submit'])) {


var =


_GET [' a_id'];
_GET['a_id'];


这篇关于如何在不更改图像字段的情况下更新记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆