Database Articles
  Home arrow Database Articles arrow Storing Images in Database
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE ARTICLES

Storing Images in Database
By: Hermawan Haryanto
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2002-12-29

    Table of Contents:
  • Storing Images in Database
  • Database Preparation
  • Start Coding
  • Viewing the Images
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Storing Images in Database


    (Page 1 of 5 )

    Learn how to store images from a HTML form into a database and then display those same images.

    Hi, today we'll talk about how to store image files in a database. Storing images in database is easy and has some advantages. Use this method only if you think this is the best solution that you come up with on your project. I've created a zip file for ever file that you need to understand this tutorial. Download it here.

    Understanding Upload Process

    Before we start building our application, I think it's a good idea for us to understand how is the upload process working. First thing we should remember that in the html forms for uploading files, we should type enctype=multipart/form-data. With that property of a form, we told the browser to prepare the given file to be uploaded to the server to be processed.

    Next, when web user selects a file on his local computer or network drive then he clicks the submit button, the file is uploaded to the temporary directory on the server with a random name. Now what the script does is grab that file from temporary directory and put it anywhere you want. You can use copy() or move_uploaded_file() or any other function that you would like. On this sample that we will discuss here we are going to put that file into a database.

    More Database Articles Articles
    More By Hermawan Haryanto


       · I was trying to run this code in PHP 4.3.4 with MySQL 4.0.17 on Apache 2.0.48 and...
       · I found that having 2 bits of code in PHP kind of cumbersome. Also we already had a...
       · When it uploads to the server, the images are severly MESSED UP.Here's an...
       · were you able to make this work? it's not working on my side eventhough i used...
       · i get this error in my browser when i execute...
       · i get this error in my browser when i execute...
       · i get this error in my browser when i execute...
       · i get this error in my browser when i execute...
       · i get this error in my browser when i execute...
       · This is very nice and functional script - thank your. I have one problem. I need...
       · Hi, Firstly the code was great and I managed to get it running (as written)...
       · I've adjusted my PHP.ini file to allow very large files but i still can't upload...
       · The problem is the MAX_ALLOWED_PACKET in your mySQL configuration. When a query is...
       · Thanks!I wasn't even thinking about mysql varibles.
       · Great script, everything seems to insert okay, but I get the following message when...
       · <?php// index.php - by Hermawan Haryanto...
       · <?php#--------------------------------------------------##DB...
       · Thanks...Great Tutorial-and mod...I am still picking this all up-but the final...
       · got this example script to work nicely for GIFs and BMPs but PJPEGs fail to display...
       · i went through, used this script fine and went through the comments as well and used...
       · Change the following line from:$str .= "<img...
       · When I upload an image it won't upload any more. If I delete that 1 image then it...
       · hi i really like the way this script uploads images and displays thumbnails on the...
       · These sre the errors I am gettingUsing win XPPHP 2.5Warning:...
       · Along with the remove ability, How about an edit?
       · can I store html page (with its images) in database??
       · Hello, I seem to get some problems with an unexpected ; on line 66 in the code. Can...
       · I was having issues displaying the image in a browser. After a lot of...
     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek