1

我有一个错误“致命错误:在第 28 行的 /data/home/.../.../.../.../upload_image.php 中的非对象上调用成员函数 upload_image()” . 函数 upload_image() 在 image.func.php 文件中,我找不到错误。在 upload_image() 函数中也是一个缩略图函数和一个图像处理函数,所以我认为错误的可能性很大。我正在尝试从错误处理中获取更多详细信息,但我没有得到任何比这个致命错误更多的信息。

upload_image 函数如下所示;

    class Images{ 
private $db;

public function __construct($database) {
$this->db = $database;
}

public function upload_image($image_temp, $image_ext, $album_id) {
global $thumbs;
$image_name = $_FILES['image'] ['name'];
$time       = time();

$query = $this->db->prepare("INSERT INTO `images` VALUES (?, ?, ?, ?, ?, ?)");

$query->bindValue(1, $image_id);
$query->bindValue(2, $image_name);
$query->bindValue(3, $_SESSION['id']);
$query->bindValue(4, $album_id);
$query->bindValue(5, $time);
$query->bindValue(6, $image_ext);

try{

$query->execute();

$image_id = $this->db->lastInsertId();
$image_file = $image_id.'.'.$image_ext;

move_uploaded_file($image_temp, 'uploads/'.$album_id.'/'.$image_file);      

$thumbs->create_thumb('uploads/'.$album_id.'/', $image_file, 'uploads/thumbs/'.$album_id.'/');

$source_image = 'uploads/'.$album_id.'/'.$image_file;;
$destination = 'uploads/'.$album_id.'/'.$image_file;
$tn_w = 900;
$tn_h = 600;
$quality = 100;
$wmsource = 'watermark.png';    
   $this->image_handler($source_image,$destination,$tn_w,$tn_h,$quality,$wmsource);                                                                                             
}catch(PDOException $e){
die($e->getMessage());
}
}
}

在这里,我尝试使用 try 和 catch 块更接近错误。

init.php 看起来像这样;

session_start();
require 'connect/database.php';
require 'classes/users.php';
require 'classes/general.php';
require 'classes/album.func.php';
require 'classes/image.func.php';
require 'classes/thumb.func.php';
require 'classes/bcrypt.php';

error_reporting(1);

$users      = new Users($db);
$general    = new General();
$albums     = new Albums($db);
$Images     = new Images($db);
$bcrypt     = new Bcrypt(12);
$thumbs     = new Create_thumb();

$errors = array();

if ($general->logged_in() === true)  {
$user_id    = $_SESSION['id'];
$user       = $users->userdata($user_id);
}

错误报告为 1。

是否有更多的可能性来接近错误?谢谢...

4

0 回答 0