使用class.upload.php编辑上传的图像

时间:2015-06-26 16:35:50

标签: php mysql image file edit

我使用class.upload.php创建了简单的上传系统,并且在向数据库中添加新内容时效果很好。但是当我需要编辑我的条目时,我有问题。在编辑条目时,我不想编辑图像,但是它将其发送为空白,如果我再次选择图像,它也会将其发送为空白。这是我的代码。

可以解释我的问题。

<?php require_once("conn.php");
require_once ("class.upload.php");

$catid = $_POST['catid'];
$title = $_POST['title'];
$descc = $_POST['descc'];
$keyw = $_POST['keyw'];
$message = $_POST['message'];
$Image = $_FILES['Image'];
$randnum = rand();
$foo = new upload($Image);
$filee = './Image'; 
 if ($foo->uploaded) { 
 $foo->image_resize = true;
 $foo->file_new_name_body = $randnum;
 $foo->image_x = 550;
 $foo->image_y = 440;
 $foo->process($filee);
 if ($foo->processed) { 
 echo 'Image uploaded.';
 echo $foo->file_dst_name;
 $foo->clean();
 } else {
 echo 'Error. : ' . $foo->error;
 }
 }
$Image7 = $foo->file_dst_name;
    if($_GET[pass] == 1)
    {   
        if(!isset($_POST[catid]) || empty($_POST[catid])){
            $hata = "Required area.";
        }
        if(!isset($_POST[title]) || empty($_POST[title])){
            $hata = "Required area.";
        }
        if(!isset($_POST[descc]) || empty($_POST[descc])){
            $hata = "Required area.";
        }       
        if(!isset($_POST[keyw]) || empty($_POST[keyw])){
            $hata = "Required area.";
        }
        if(!isset($_POST[message]) || empty($_POST[message])){
            $hata = "Required area.";
        }
        if(!$hata){
            mysql_query("UPDATE product SET
                catid='$_POST[catid]',
                title='$_POST[title]',
                descc='$_POST[descc]',
                keyw='$_POST[keyw]',
                message='$_POST[message]',
                Image='$_POST[Image]'
                WHERE id='$_POST[id]'
                "); 
            $mesaj = "OK!";
        }

    }
    $sonuc = mysql_query("select * from product WHERE id='$_GET[product]'");
    $edit = mysql_fetch_array($sonuc);
    $sonuc1 = mysql_query("select * from category");
    $edit1 = mysql_fetch_array($sonuc1);
?>

2 个答案:

答案 0 :(得分:0)

尝试更改更新查询

at Image ='$ _ POST [Image]'

with Image ='$ Image7'

答案 1 :(得分:0)

Fatih你可以在sql查询中使用变量(即$ saved_image_name)而不是$ POST [Image]。如果上传了db field的旧值,则将此变量设置为新名称。

<Reference URI="/word/_rels/document.xml.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml">
  <Transforms>
    <Transform Algorithm="http://schemas.openxmlformats.org/package/2006/RelationshipTransform">
      <xdssi:RelationshipReference xmlns:xdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" SourceId="rId3"/>
      <xdssi:RelationshipReference xmlns:xdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" SourceId="rId2"/>
      <xdssi:RelationshipReference xmlns:xdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" SourceId="rId1"/>
      <xdssi:RelationshipReference xmlns:xdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" SourceId="rId5"/>
      <xdssi:RelationshipReference xmlns:xdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" SourceId="rId4"/>
    </Transform>
    <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
  </Transforms>
  <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  <DigestValue>
  </DigestValue>
</Reference>

... ...