944,126 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 522
  • PHP RSS
Nov 5th, 2009
0

Uploading to specific field in datatbase

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
SuntechWebsites is offline Offline
39 posts
since Oct 2009
Nov 5th, 2009
-1
Re: Uploading to specific field in datatbase
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
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006
Nov 9th, 2009
0
Re: Uploading to specific field in datatbase
Thanks. Thats pretty much what I figured. Works good.
Reputation Points: 10
Solved Threads: 0
Light Poster
SuntechWebsites is offline Offline
39 posts
since Oct 2009
Nov 9th, 2009
0
Re: Uploading to specific field in datatbase
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.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 10th, 2009
0
Re: Uploading to specific field in datatbase
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?
Reputation Points: 10
Solved Threads: 0
Light Poster
SuntechWebsites is offline Offline
39 posts
since Oct 2009
Nov 10th, 2009
0
Re: Uploading to specific field in datatbase
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.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: monitor size
Next Thread in PHP Forum Timeline: Cron Jobs





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC