Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:18:28+00:00 2026-06-08T01:18:28+00:00

For the past two days, I have been working on a project, and no

  • 0

For the past two days, I have been working on a project, and no matter what I try, I get an error of some sort, or something just doesn’t work. At this point, I am being told that I’m calling an undefined method, upload:prepare(), which is true because the class is called upload, and the statement is $this->prepare()….etc etc.

I am so frustrated that no matter what I do, I cannot figure this out.

classes.php

<?php
require('config.php');
error_reporting(E_ALL);
/*
 * Classes required by the script
 * 
 */

class database extends PDO
{
    public $conURL;

    public function __construct($config) {
        $conURL = "mysql:host=" . $config['host'] . ";dbname=" . $config['db'];
        try {
         parent::__construct($conURL, $config['user'], $config['pass']);
        } catch (PDOException $e) {
            $e->getMessage();
        }
    }       
}

class upload
{
    public $_FILES;

    public function uploadFile() {
        if ($_FILES['file']['size'] >= 2000000) {
           echo "File is too large!";
        }
        elseif (isset($_FILES['file'])) {
           $stmt = $this->prepare("INSERT INTO upload (name, type, size, content) VALUES (?, ?, ?, ?)");
           $stmt->execute(array($_FILES['file']['name'], $_FILES['file']['type'], $_FILES['file']['size'], $_FILES['file']['file']));
        }
    }
}

config.php

<?php
$config = array(
        'host' => 'localhost', // db host
        'user' => 'root', // db user
        'pass' => 'mypassword', //db pass
        'db' => 'files' // db name
);

upload.php

<?php
error_reporting(E_ALL);
require('config.php');
require('classes.php');

$dbh = new database($config);
$upload = new upload();
$upload->uploadFile();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:18:29+00:00Added an answer on June 8, 2026 at 1:18 am

    You’re attempting to call the prepare function of upload, rather than database. Try this:

    class upload
    {
        public $_FILES;
    
        public function uploadFile($config) {
            $db = new database($config);
            if ($_FILES['file']['size'] >= 2000000) {
               echo "File is too large!";
            }
            elseif (isset($_FILES['file'])) {
               $stmt = $db->prepare("INSERT INTO upload (name, type, size, content) VALUES (?, ?, ?, ?)");
               $stmt->execute(array($_FILES['file']['name'], $_FILES['file']['type'], $_FILES['file']['size'], $_FILES['file']['file']));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying for the past two days now to implement Admob ads
I've been asking a question or two over the past few days of working
I have been looking following tutorials online for the past two days and I
I have been searching for a solution for the past two days now. I
From the past two days i have been diving into the concepts of OOPS
I have been trying these for past two days and getting stuck at same
For the past two days i have been looking around the net to find
I have been doing Google search for the past two days and couldn't find
I've spent the past two days just trying to enable the sending of email
I have been building my own carasol over the past few days. My Jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.