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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:47:46+00:00 2026-06-01T12:47:46+00:00

I need to create a simple mySQL database with a field for an image.

  • 0

I need to create a simple mySQL database with a field for an image.

Is there a simple example that explains the type of field and how to upload from a directory on the server, etc…?

Thanks.

Erik

  • 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-01T12:47:48+00:00Added an answer on June 1, 2026 at 12:47 pm

    Here is a basic example of BLOB Storage:

    CREATE TABLE IF NOT EXISTS `files` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `filename` varchar(255) DEFAULT NULL,
      `ext` varchar(5) DEFAULT NULL,
      `filedata` blob,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
    
    <?php
    $db = mysql_connect('localhost', 'user', 'pass') or die('Could not connect:' . mysql_error());
    mysql_select_db('the_database',$db);
    
    if(isset($_FILES['upload'])){
    
        if (is_uploaded_file($_FILES['upload']['tmp_name'])) {
            $file_parts = pathinfo($_FILES['upload']['name']);
    
            $file['name'] =$file_parts['filename'];
            $file['ext']  =$file_parts['extension'];
            $file['data'] =addslashes(file_get_contents($_FILES['upload']['tmp_name'])); 
    
            mysql_query('INSERT into files (id,filename,ext,filedata) values ("","'.$file['name'].'","'.$file['ext'].'","'.$file['data'].'")',$db) or die(mysql_error());
            $notice="File Uploaded successfully";
        }
    }
    ?>
    
    
    <html>
    <head>
    <title>BLOB Upload</title>
    </head>
    <body>
    
    <form method="POST" enctype="multipart/form-data" action="">
    <h1 align="center">BLOB Upload</h1>
      <p align="center"><input type="file" name="upload" size="40"></p>
      <p align="center"><input type="submit" value="Upload"></p>
      <?php if(isset($notice)){echo '<p align="center">'.$notice.'</p>';}?>
    </form>
    
    </body>
    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have very simple problem. I need to create model, that represent element of
I'm just trying to create a new MySQL database with a few simple tables.
I need to create simple reusable javascript object publishing several methods and parameterized constructor.
I need to create a simple editor using a RichTextBox control in a windows
I need to create a simple Chat system like facebook chat and a twitter-like
I need to create some simple effects for the layers which I have created
For the purpose of the question I need to create a simple fictitious scenario.
Sometimes you need to create a very simple single file application in Qt4. However
How to create simple PHP COMET server page displaying current time? I need code
I have simple table creating script in Postgres 9.1. I need it to create

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.