1. Home
  2. Computing & Technology
  3. PHP / MySQL

Storing User Submitted Data and Files in MySQL

By Angela Bradley, About.com

5 of 7

Adding Uploads Explained

The first thing this code actually does is connect to the database (you need to replace this with your actual database information.)

Next it uses the ADDSLASHES function. What this does is add back slashes if needed into the file name so that we won't get an error when we query the database. For example if we have Billy'sFile.gif, it will convert this to Billy\'sFile.gif. FOPEN opens the file and FREAD is a binary safe file read, so that the ADDSLASHES is applied to data within the file if needed.

Next we add all of the information our form collected into our database. You will notice we listed the fields first, and the values second so we don't accidently try to insert data into our first field (the auto assigning ID field.)

Finally we print out the data for the user to review.

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP with MySQL
  5. SQL Form - SQL File - File Upload

©2009 About.com, a part of The New York Times Company.

All rights reserved.