Jump to content


Photo

Storing files in a database?


  • Please log in to reply
2 replies to this topic

#1 Silver

Silver
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 26 April 2003 - 01:35 PM

Hello!

I\'m trying to make a script where users can upload their files, but the files they upload can only be downloaded X amount of times. After they\'ve been downloaded so many times in an ideal world they\'d be automatically removed, though just to be made so people couldn\'t download them anymore would be great.

I\'ve made the upload part, I was told the best way would probably be to -

1. Store the files in a database and have a field that has a value that is how many times it can be downloaded.
2. Then a page that allows users to download.
3. For each download you can decrement that download field by one.
4. When you display the link for all the download files you can display
all the downloads that do not have your available download field = 0...

Either could I have some help in how to store files in a mySQL database, or could you advise me of a better way to do this please?

Thanks!

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 26 April 2003 - 01:55 PM

storing in db means storing the link of the file.

u can retrive this link and show to the users

Now what u have said is ok and i think u can goahead doing that.

u have to maintain a value in the db which u have to decrement or incerement as u said.

But be sure u do the update in a intermediate page. Like if dont have a intemediate page when I click on the refresh ur value will be still decremented weven though i havent downloaded them.
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 Silver

Silver
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 26 April 2003 - 02:20 PM

Ok, let\'s start at the beginning, I\'ve never done this before and am still quite a newbie to php ;)

storing in db means storing the link of the file.

u can retrive this link and show to the users


Ok, how do I do that?

Now what u have said is ok and i think u can goahead doing that.


Good :) Now I just need to learn how ;)

u have to maintain a value in the db which u have to decrement or incerement as u said.


I have the right theory then, if I can just learn how to put it into practise it should be great!

But be sure u do the update in a intermediate page. Like if dont have a intemediate page when I click on the refresh ur value will be still decremented even though i havent downloaded them.


Which update? And how do you mean an intermediate page?

Thanks for your help :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users