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 8992337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:55:49+00:00 2026-06-15T22:55:49+00:00

I got this upload script but when I want to run it, the page

  • 0

I got this upload script but when I want to run it, the page returns blank. There is something wrong, but I cannot figure out where the error is and how to fix it. I would appreciate if someone helped me to make this script work ! MANY thanks !

<?php
    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/png")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br>";
        echo "Type: " . $_FILES["file"]["type"] . "<br>";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

        if (file_exists("upload/" . $_FILES["file"]["name"]))
          {
          echo $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
            include 'db.php';
            mysql_query("INSERT INTO `members`(img) VALUES ('$_FILES["file"]["name"]')");
            include 'succes.php';
            }
        }
      }
    else
      {
      echo "Invalid file";
      }
    ?>
  • 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-15T22:55:51+00:00Added an answer on June 15, 2026 at 10:55 pm

    Please, don’t use mysql_* functions in new code. They are no longer maintained and the deprecation process has begun on it. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi – this article will help you decide which. If you choose PDO, here is a good tutorial.

    However, check that upload/ folder has read and write permissions and use this working code:

    mysql_query("INSERT INTO `members`(img) VALUES ('" . $_FILES["file"]["name"] . "');");
    

    See that using that code there’s an SQL injection vulnerability, I suggest you to prepare queries via PDO.

    If you have to update an existing record use:

    mysql_query("UPDATE `members` SET img = '" . $_FILES["file"]["name"] . "' WHERE member_id = '" . $member_id . "';");
    

    If you have to add new image to an existing member you could try:

    mysql_query("INSERT INTO `members` (img, member_id) VALUES ('" . $_FILES["file"]["name"] . "', '" . $member_id . "');");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got most of what I want working, but this last bit requires I
I was trying to upload an image, but I got this message: finfo_open() [function.finfo-open]:
I got this traceback when trying to upload a file using put_file (source code
Got this line of code here but its not working. private void Button_Click(object sender,
I want to change the maximum file upload size in my website, for this
My python2 script uploads files nicely using this method but python3 is presenting problems
I am writing a watir script to test an upload form. But the script
I've got this script and it produces the following error: 001 Checksum failure This
I am using this ajax file upload script, and all works well in firefox
I would like to use this script to multiple file upload with jQuery v1.6.2.

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.