Simple file upload counter with ASP.NET?

How to make O simple file upload counter with ASP.NET in C #? For example, when a user clicked and downloaded a file, I want to update it +1 and store its filename in DB. when the onmouse user on the link i want to show the tooltip with the downloaded file Times.But If the user cancel the download status it will not refresh it.

+1


a source to share


1 answer


If you don't want to update if the file is not fully loaded, you will have to write your own generic handler , into which you update the database at the very end of processing.

For DB, I would recommend to have one table that stores each boot entry and where you store information about each file, for example

tblDownloads
************
DlID (GUID, not nullable, primary key)
Date (datetime, not nullable)
FileID (GUID, not nullable)

tblFiles
********
FileID (GUID, not nullable, primary key)
Url (nvarchar(255), not nullable)
Title (nvarchar(255), not nullable)
Description (nvarchar(max))

      

(Examples of data types etc. are named as they would in MSSQL ...)



To get the number of downloads of a specific file, you simply query the database for

SELECT COUNT(DlID) FROM tblDownloads WHERE FileID = @FileID

      

where @FileID

is the parameter with the required file identifier. If you want to disable URLs for all files, you can, for example, request

SELECT 
    f.FileID, f.Url, f.Title, f.Description, COUNT(d.DlID) AS DownloadCount 
FROM tblFiles f INNER JOIN tblDownloads d ON f.FileID = d.FileID 
GROUP BY f.FileID, f.Url, f.Title, f.Description

      

0


a source







All Articles