Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload files on a Mysql base ?

Status
Not open for further replies.

Moez

Technical User
Jul 3, 2001
53
FR
Hi,

I would to know if it's possible to upload documents (.doc, .zip, .ppt ...and other), in a Mysql Base ? And maybe, you also know what is the fonction to use with PHP ?

Thanks for help !
Moez
 
You can do this with a mySQL query, but it requres the file to be on the server. If you're trying to get a file from a remote system onto the server, you can first do an HTTP upload to get it on the server, and then use an insert/update statement to get the file into the database. Also, the column that the file is going to go into in the database must be type BLOB.

If you had a table called "mytable" with a two columns called "owner" and "filename", then the query would look something like this:

INSERT into mytable values('me', LOAD_FILE("absolute/path/to_file"))

or

UPDATE mytable set filename=LOAD_FILE("absolute/path/to_file") WHERE owner='me';
 
Ok, thanks for these precise informations. But, if my server is my ISP, is it also possible to do the upload on the server and after the mysql query ?
What is the type, BLOB ?

Moez

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top