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

  • Home
  • SEARCH
  • 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 8332911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:51:24+00:00 2026-06-09T02:51:24+00:00

I am having trouble with this script. It’s an image upload script and I

  • 0

I am having trouble with this script. It’s an image upload script and I am getting two errors that say the same thing:

Warning: Missing argument 1 for DoUpload::doUpload(), called in
/var/www/vhosts/mysite.net/httpdocs/mp/upload.php on line 8 and
defined in /var/www/vhosts/mysite.net/httpdocs/mp/includes/classes.php
on line 26 The file has been uploaded! Warning: Missing argument 1 for
DoUpload::doUpload(), called in
/var/www/vhosts/mysite.net/httpdocs/mp/upload.php on line 10 and
defined in /var/www/vhosts/mysite.net/httpdocs/mp/includes/classes.php
on line 26 An error occurred when uploading the file!

But as you can see in upload.php, I am passing an argument: the $_FILES array.

What do I do? (Not looking for anyone to re-write anything, I just need a little guidance in what I am doing wrong. 🙂 )

classes.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require('config.php');

// Connect to database
// Does not handle anything else
class DatabaseCon {
    public $dbh;

    // Method to connect to database
    function dbConnect($config) {
        try {
            $this->dbh = new PDO("mysql:host=" . $config['host'] . ";dbname=" . $config['dbname'], $config['dbuser'], $config['dbpass']);
            $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
        } catch (PDOException $e) {
            echo $e->getMessage();
        }
    }
}

class DoUpload {
    private $target_path = 'i/';
    public $_FILES;

    public function doUpload($_FILES) {
        $this->target_path .= basename($_FILES['file']['name']);

        if (move_uploaded_file($_FILES['file']['tmp_name'], $this->target_path)) {
            echo "The file has been uploaded!";
        }
        else {
            echo "An error occurred when uploading the file!";
        }
    }

}

upload.php

<?php
ini_set('display_errors', 1);
require_once('includes/config.php');
require_once('includes/classes.php');

$db = new DatabaseCon();
$db->dbConnect($config);

$upload = new DoUpload();

$upload->doUpload($_FILES);

$sth = $db->prepare("INSERT INTO images (filename) VALUES (?)");
$sth->bindParam(1, $_FILES['file']['tmp_name']);
$sth->execute();
  • 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-09T02:51:26+00:00Added an answer on June 9, 2026 at 2:51 am

    $_FILES is a superglobal, meaning it will be available to any part of your script regardless of scope. You shouldn’t need to pass in any arguments to your doUpload method, and you can still use the $_FILES array inside your method definition.

    Don’t know if this is what is causing the problem or not, but just a heads up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting this script to work. <asp:DropDownList CssClass=workUnit Width=80 ID=dropdownWorkUnit runat=server Visible=false
I'm having some trouble figuring this out. I have a script that checks a
I'm having trouble converting this 5 star rating script that works perfect with jquery
I'm having trouble getting setResultsName to work for me in this script, even when
I'm having with trouble with this script... Everything in it is working except the
I'm having trouble with this PHP script where I get the error Fatal error
I am having trouble with this error message as the line it errors on
I am having trouble getting this invisibilityOfElementLocated() method to work. Here is the code
I am having trouble coming up with a jQuery script that will all content
I'm using SQL Server MS. I'm having trouble writing this script: CREATE VIEW rental_view

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.