Saturday, September 4th, 2010

Upload and store files in Mysql using PHP : Part 1 – Design MySql Table

A MySQL database can be used to store files uploaded using PHP.The table columns must be created using BLOB columns to hold the binary file.The blob column can hold up to 65,535 characters.

Example code:

<?php
  $con = mysql_connect("localhost", "", "");
  mysql_select_db("w3m");
  $sql = "CREATE TABLE updfiles ("
      . " id INTEGER NOT NULL AUTO_INCREMENT" 
      . ", name VARCHAR(80) NOT NULL"
      . ", type VARCHAR(80) NOT NULL"
      . ", size INTEGER NOT NULL"
      . ", content BLOB"
      . ", PRIMARY KEY (id)"
      . ")";
  mysql_query($sql, $con); 
  mysql_close($con); 
?>
Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

Tags: , , ,

Readers Comments (1)

  1. [...] original here: PHP File Handling | Upload and store files in Mysql using PHP … Share and [...]




Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


Latest Additions

Popular User Submitted Links

1


Hosted & Optimized JS Libraries – Cached Commons

1


Multi-File Uploader & Resizer – Agile Uploader

1


Open source online notebook-to-do-list manager

1


3 tier app design in silverlight using azure & RIA services

1


Polymaps – A JS Library For Image & Vector-Tiled Maps

eXTReMe Tracker