Jump to content

Storing files in a database?


Silver

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.