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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:14:27+00:00 2026-06-08T00:14:27+00:00

I need to retrieve form values to insert.php file in order to store them

  • 0

I need to retrieve form values to insert.php file in order to store them in the database. However one of the elements in the form is a file chooser dialog to upload an image file in JPG or other file format.

I found this code online to send the image via a post request, but cannot get it to work correctly

$pic=($_FILES['photo'][image']); 

It only displays the name of the file and not the actual file itself

  • 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-08T00:14:29+00:00Added an answer on June 8, 2026 at 12:14 am

    First of all you need to add the enctype attribute to your HTML form. Like this:

    <form action="page.php" method="post" accept-charset="utf-8" enctype="multipart/form-data">
        <input type="file" name="photo" id="photo" />
        <input type="submit" value="Upload" />
    </form>
    

    Next, when this will be sent on the next page use the $_FILES global array instead of the $_POST array to retrieve the image.

    <?php
        move_uploaded_file( $_FILES['photo']['tmp_name'], "/var/www/image.jpg" );
        echo("<img src='image.jpg'");
    ?>
    

    All text data will be sent using $_POST but the file will be transferred using $_FILES.

    Edit: If you further want to insert this uploaded data in the table (although this is never recommended and is a huge performance loss)

    $image = file_get_contents( "/var/www/image.jpg" );
    $image = addslashes( $image );
    ...
    $sql = "INSERT INTO pictures(image) VALUES('" . $image . "')";
    //remaining MySQL and PHP code
    

    Note: Here I am considering /var/www as my web folder which is configured as default localhost on Linux machines.

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

Sidebar

Related Questions

I need to write values from form in flex to an oracle database. I
I have retrieve the Order table form database using hibernate criteria option. In my
I need a php script that will use the values of the form's checkboxes
I need to retrieve random rows from SQL Server database. I am looking for
I create a form wherein the user enters some values but I now need
I want to retrieve some values from my url and post them in a
I like to retrieve and store the values of an HTML table from a
Hi I'm new to Oracle 10g. I need retrieve the all the sublist from
I need to retrieve a value from a website (can vary and I have
I need to retrieve information from two separate models which are similar but not

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.