How does mysql-php record a file downloaded by the user?

Source: Internet
Author: User
Similar to using Baidu Library, downloading a file requires one download coupon. When Downloading this file for the first time, one download coupon will be deducted, when this account downloads this file again, the download coupon will not be deducted. I want to have a download_records table, which is used with the users table... similar to using Baidu Library, downloading a file requires one download coupon. When Downloading this file for the first time, one download coupon will be deducted, when this account downloads this file again, the download coupon will not be deducted.

I want to have a download_records table, which is associated with the users table one to multiple. Every time a file is downloaded, a record is written to the download_records table, as shown in the following figure:

id   download_record  user_id1    ...              1232    ...              123

So what is the record for this download_record field? Is it the path + file name of this file? Or something else?

Reply content:

Similar to using Baidu Library, downloading a file requires one download coupon. When Downloading this file for the first time, one download coupon will be deducted, when this account downloads this file again, the download coupon will not be deducted.

I want to have a download_records table, which is associated with the users table one to multiple. Every time a file is downloaded, a record is written to the download_records table, as shown in the following figure:

id   download_record  user_id1    ...              1232    ...              123

So what is the record for this download_record field? Is it the path + file name of this file? Or something else?

You have created an association table between your account and the downloaded file.

Ideas:
Direct download is not supported, that is, no resolution is provided during the download. Prohibit download from the server address/av. avi. Change to xxx. php? Filename = av. avi to parse and download. Then write the business logic in xxx. php.

You can record your file ID. If your file has multiple types and stores multiple locations, you can repeat this ID and add another type record file type.
File type and ID plus unique restrictions

Subject: Is the downloaded resource uploaded in the background? The background upload should have an ID. You can record the resource ID, user ID, and download time in the resource download table =. Others will be determined based on project requirements.

Record File id

id    article_id    user_id   down_num   

When downloading, you can determine whether the user has downloaded the file. If you have downloaded the file, no credits are deducted. down_num indicates the number of downloads. If you have not downloaded the file, you do not need to add a record.

I suggest creatingFile TableAndUser table.
Creating a table only records the file id and user id.
If you want to download expired after a certain period of time, you can add a timestamp field

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.