Hi All,

Im trying to find a method to allow files to be:

1. Uploaded and stored in a mysql database
2. List them, with "change" and "delete" options
3. Allow them to be downloaded, or even just viewed

I have tried using blobs, but to no avail. I have used a great number of scripts, all of which havent worked at all. i have posted other threads about these errors but to no avail.

Can anybody help me sort this out? Even if its not really using a blob, but a URL instead that would be a great help.

Recommended Answers

All 3 Replies

Member Avatar for diafol

You definitely want to store urls, NOT the file itself.

See the php manual for file uploading ( http://uk2.php.net/manual/en/function.move-uploaded-file.php ). To that tag on a mysql function that writes the path/filename and other file-related data to your table.


File uploading is notoriously problematic if you've never done it before. File locations are typically accessed from the virtual root. If you place $_SERVER . "/myuploads/" for example as your destination, you should be fine (if "/myuploads/" is a top-level folder under htdocs or public_html). However, if you can reference the upload folder by a relative reference, you could try that. In addition, your urls in the mysql table SHOULD NOT include this virtual root info, they should be written with an absolute reference: "/myuploads/...."

I'm sure other users have different ideas, but there's my input for what it's worth.

Ok thats brilliant.

Now im thinking that files can be uploaded using the usual "browse" and upload to a folder. Are you able to give a code example as to how i could get php to pick up all files in a specific directory and then display to screen as clickable/downloadable url?

Thanks for your input

Member Avatar for diafol

Yes - form upload button - quite straightforward. Check out the php manual on uploads and Google "php uploads". Should be millions of 'em. Search this forum too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.