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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:36:16+00:00 2026-05-26T17:36:16+00:00

I am in the early stage of developing a bidding system whereby users are

  • 0

I am in the early stage of developing a bidding system whereby users are able to insert items that they want to sell. Here is the script to copy the image from the temporary path and store the path of the image to another folder.

    define ("MAX_SIZE","10000");

    //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension.
    function getExtension($str) {
        $i = strrpos($str,".");
        if (!$i) {
            return "";
        }
        $l = strlen($str) - $i;
        $ext = substr($str,$i+1,$l);
        return $ext;
    };

    //This variable is used as a flag. The value is initialized with 0 (meaning no error found) and it will be changed to 1 if an errro occures. If the error occures the file will not be uploaded.
    $errors = 0;

    //Checks if the form has been submitted
    if (isset($_POST['Submit']))
    {
        //Reads the name of the file the user submitted for uploading
        $image=$_FILES['image']['name'];

        //If it is not empty
        if ($image)
        {
            //Get the original name of the file from the clients machine
            $filename = stripslashes($_FILES['image']['name']);

            //Get the extension of the file in a lower case format
            $extension = getExtension($filename);
            $extension = strtolower($extension);

            //If it is not a known extension, we will suppose it is an error and will not upload the file, otherwize we will do more tests
            if (($extension != "jpg") &&
                ($extension != "jpeg") &&
                ($extension != "png") &&
                ($extension != "gif"))
            {
                //Print error message
                echo '<h1>Unknown extension!</h1>';
                $errors=1;
            }
        else
        {
            //Get the size of the image in bytes
            //$_FILES['image']['tmp_name'] is the temporary filename of the file in which the uploaded file was stored on the server
            $size=filesize($_FILES['image']['tmp_name']);

            //Compare the size with the maxim size we defined and print error if bigger
            if ($size > MAX_SIZE*111111111111024)
            {
                echo '<h1>You have exceeded the size limit!</h1>';
                $errors=1;
            }

            //We will give an unique name, for example the time in Unix time format
            $image_name=time().'.'.$extension;

            //The new name will be containing the full path where will be stored (images folder).
            $imagepath='C:\\xampp\\htdocs\\biddingsystem\\Images\\' . $image_name;

            //We verify if the image has been uploaded, and print an error instead
            $copied = copy($_FILES['image']['tmp_name'], $imagepath);
            if (!$copied)
            {
                echo '<h1>Picture upload failed!</h1>';
                $errors=1;
            }
        }
    }
}

//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors && isset($_POST['image']))
{
    echo "<h1>Picture Uploaded Successfully! Try again!</h1>";
}

Then, I inserted the image path along with other data to a MySQL database with the script below and tried to display them back to the user using a table. Other data worked out fine but for the image display (imagepath), only the path of the image gets displayed, not the image itself.

mysql_query("INSERT INTO items
    (username, item, price, description, start_date, start_time, imagepath)
    VALUES    ('$username', '$_POST[item]', '$_POST[price]', '$_POST[description]','$_POST[start_date]', '$_POST[start_time]', '$imagepath') ")
    or die ("Error - Couldn't add item");

    echo "Item added successfully";
    echo "<h1>You have added the following item:</h1>";
    $sql = "SELECT item, price, description, start_time, start_date, imagepath FROM items WHERE username = '$username' AND item='$_POST[item]'";
    $result = mysql_query($sql);

$row = mysql_fetch_assoc($result);
echo"<table border=2>

         <tr><td>Item</td>
             <td>Price</td><td>Description</td><td>Start time</td><td>Start date</td><td>Picture</td></tr>

         <tr><td> $row[item]</td>
              <td> $row[price]</td>
              <td> $row[description]</td>
             <td> $row[start_time]</td>
             <td> $row[start_date]</td>
             <td> $row[imagepath]</td>
         </tr>
     </table></br>";

I have tried using <img src="<?php $imagepath ?>"> to show the image but to no avail. I have even tried storing the actual image itself in the database using the BLOB type. However, the result is a page filled with strange characters. How do I fix this problem?

  • 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-05-26T17:36:17+00:00Added an answer on May 26, 2026 at 5:36 pm

    You are confusing the filesystem path and web URL. You have to store only /biddingsystem/Images/ part or even just only name and generate full path dynamically at display time.

    Also note that you aren’t formatting your data properly, which will lead to some bugs and security vulnerabilities. I’ve explained formatting rules in my earlier answer, to Stack Overflow question How to include a PHP variable inside a MySQL insert statement.

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

Sidebar

Related Questions

I am in the early stages of developing a database-driven system and the largest
I'm in early development stage of developing a web application. Im currently reviewing as
I am in a early stage of a project, graphically modelling the system structure.
I am currently in the early stages of developing a couple web applications, I
This is just an early stage test of creating and writing a file to
I'm designing a site. It is in a very early stage, and I have
I'm working on early designs for an application that needs to start out small
I'm in early (pre-coding) stages of developing a mobile web application using jQuery Mobile
I'm in a very early stage of writing a small music/rhythm game in Java
Currently in the early stages of developing a very large project using ASP.Net MVC.

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.