Hello, Gurus . I upload my product catalog to one of my ecommerce site . I would like to trace how many times my catalog had been download . At present, my site is using asp scripts . Are there any asp scripts that can help me . I appreciate your help . thanks . (PS. are there any php version of the scripts too ?)
you could use something simple like: (download.asp): <% Dim fso, f, cnt On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(Server.MapPath("downloads.txt")) cnt = f.ReadLine cnt = cnt + 1 f.Close Set f = fso.OpenTextFile(Server.MapPath("downloads.txt"), 2, True) f.WriteLine cnt f.Close Set f = Nothing Set fso = Nothing Response.Redirect "catalog.pdf" %> Code (markup): This would record the number of hits in a file 'downloads.txt'. You would then link to the file like: <a href="download.asp">View Catalog</a> Code (markup):
camjohnson95 Thanks for your feedback . So I can change the following code Response.Redirect "catalog.pdf" to "catalog.zip" or other file format . The catalog.pdf/catalog.zip must be on the same direct of download.asp . Am I right ?
yep, well it doesnt have to be, but with that code it would. and downloads.txt would also be in the same directory. come to think of it: Response.Redirect Server.MapPath("catalog.zip") Code (markup): for that last line might be better. If you wanted catalog in a different directory a / in front of the file name(catalog.zip) will bring it back to the root directory. so you could go from there.
Hello, camjohnson95 I upload the scripts to my site . I can download the catalog.zip . But the count doesn't work . (I set initail number 1 to download.txt , but I test to download the file and the count doesn't work. )
just note that the filename I have used is 'downloads.txt' with an 's' on the end. make sure that your refresh downloads.txt when viewing it too ensure it is not the cached version of the file.