Heres one for ya...
Lets say you have a mysql database with multiple entries (clients). Each one has a field for name, username ect. There is also one for say storing a doc file for billing. How can I make it so I can upload a file to just a specific clients "billing" field in the database?
Oooooooor, do I store these files on the server? Which would bring me to the question of how to upload the files to a specific directory though a web browser.
I am trying to figure out the best way to create an "Admin control panel" to be able to update the clients without having to use an ftp program.
Mabey thats just the best way. I am looking for suggestions and code. Im still pretty new at this.
I also have a post looking for ways to display these files for the clients on thier login page. I used the echo statment and only got a coded version of the file.

Member Avatar for diafol

You could save all the info in a blob field (no physical file - just some encoded info in a field, which can produce a file on demand), OR just store an url/path for a physical file stored in a certain folder.

E.g.

users table
id (PK)
username
... etc ...

billing table
id (PK)
user_id (Foreign Key on id in users)
dated (billing date)
amount (Billing Amount)
reconciled (Y/N)
invoice_file ***(this is where you store the file's path)
...other fields...

You shoud be able to store a pdf file of the invoice, otherwise you could produce it dynamically from billing info - you can use something like fpdf for either approach

Thanks. Thats pretty much what I figured. Works good.

Hey.

I wrote an article that explains in detail how you would upload a file into a MySQL database. (Linkage).
In case you choose to go that route.

Ok, now, how can I password protect the directory that holds the file so its not accessable by others, but is to the logged in user?

Ok, now, how can I password protect the directory that holds the file so its not accessable by others, but is to the logged in user?

You could store the files outside the web-root, so they can't be reached by a HTTP request, and have a PHP file that forwards them to users that are logged in.

There are also ways to use .htaccess files (Apache only) to restrict access to specific directories, but that won't integrate with PHP as easily.

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.