Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从数据库PDO PHP编辑图像_Php_Html_File_Pdo - Fatal编程技术网

无法从数据库PDO PHP编辑图像

无法从数据库PDO PHP编辑图像,php,html,file,pdo,Php,Html,File,Pdo,我可以使用此代码成功地从数据库保存图像 if(isset($_POST['btn-update'])){ $id = $_REQUEST['id']; $sql = "SELECT * FROM article WHERE id=:id"; $query= $db_con->prepare($sql); $query->execute(array(':id' => $id)); while($row=$query->fetc

我可以使用此代码成功地从数据库保存图像

if(isset($_POST['btn-update'])){


    $id = $_REQUEST['id'];

    $sql = "SELECT * FROM article WHERE id=:id";
    $query= $db_con->prepare($sql);
    $query->execute(array(':id' => $id));

    while($row=$query->fetch(PDO::FETCH_ASSOC)){
        $images_ = $row['image'];
        $files_ = $row['file'];
    }

$file_image = $_FILES['image-files'];
$file_image_Name = $_FILES['image-files']['name'];
$file_image_TmpName = $_FILES['image-files']['tmp_name'];
$file_image_Size = $_FILES['image-files']['size'];
$file_image_Error = $_FILES['image-files']['error'];
$file_image_Type = $_FILES['image-files']['type'];

if(!empty($_FILES['image-files']['tmp_name'])){
//handle first upload
    $file_image_Ext = explode('.', $file_image_Name);
    $file_image_ActualExt = strtolower(end($file_image_Ext));
    $file_image_allowed = array("jpg", "jpeg", "png");

    if(in_array($file_image_ActualExt, $file_image_allowed)){
        if($file_image_Error === 0){
            if($file_image_Size < 1000000){
                $file_image_NameNew = "image-".uniqid('',true).'.'.$file_image_ActualExt;
                $file_image_Destination = 'uploaded_files/uploaded_files_articles_images/' .$file_image_NameNew;
                move_uploaded_file($file_image_TmpName, $file_image_Destination);
            }else{
                echo "You file size is too big!";
            }
        }else{
            echo "There was an error uploading the file!";  
        }
    }else{
        echo "You cannot upload files of this type!";
    }

}else{
    $file_image_NameNew = '';
}

if($user->InsertArticle($articleTitle,$date_today,$bodyContent,$file_image_NameNew))
{
    header("Location:admin-index?UploadedSuccesfully!");
}
}
这是我的
UpdateFile方法

public function UpdateFile($id,$title, $content, $image){
        try{
            $stmt = $this->db->prepare("UPDATE article SET title=:title, content=:content, image=:image WHERE id=:id");

            $stmt->bindParam(":title", $title);
            $stmt->bindParam(":content", $content);
            $stmt->bindParam(":image", $image);
            $stmt->bindParam(":id", $id);

            $stmt->execute();

            return $stmt;

        }catch(PDOException $ex){
            echo $ex->getMessage();
        }
    }
谁能帮我一下吗

编辑:


文章标题
>	

更新
如果没有HTML,就无法判断您是否使用了相同的文件数组名称。哦,很抱歉。I'@FunkFortyNiner我已经编辑了先生我的问题使用以下错误处理链接查看发生了什么:没有错误先生
public function UpdateFile($id,$title, $content, $image){
        try{
            $stmt = $this->db->prepare("UPDATE article SET title=:title, content=:content, image=:image WHERE id=:id");

            $stmt->bindParam(":title", $title);
            $stmt->bindParam(":content", $content);
            $stmt->bindParam(":image", $image);
            $stmt->bindParam(":id", $id);

            $stmt->execute();

            return $stmt;

        }catch(PDOException $ex){
            echo $ex->getMessage();
        }
    }