View Single Post
  #5 (permalink)  
Old 08-18-03, 06:17 PM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Hey Shane, i have another script i was using before, but the way it works is it uploads the files into a folder and then the download page reads all the files in the folder and lists them on the page. I want the included pictures of the upload/download pages to look the same, but is there any way to convert code into something so it will read of a database (files.mdb).

upload code: (scripts_upload.asp)
----------------------------------------------

<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim oConn
Dim oRs
Dim intCount
Dim fileCount
Dim curDir
Dim strSQL

intCount=0

' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

' Only allow txt or htm files
' ***************************
mySmartUpload.AllowedFilesList = "zip,exe"

' Deny physical path
' *******************
mySmartUpload.DenyPhysicalPath = True

' Only allow files smaller than 50000 bytes
' *****************************************
mySmartUpload.MaxFileSize = 5120000

' Deny upload if the total fila size is greater than 200000 bytes
' ************************************************** *************
mySmartUpload.TotalMaxFileSize = 5120000

' Upload
' ******
mySmartUpload.Upload

' Connect to the DB
' *****************
Set oConn = Server.CreateObject("ADODB.Connection")
curDir = Server.MapPath("../databases/scripts.mdb")
oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"

' Open a recordset
' ****************
strSQL = "SELECT FILENAME,FILE FROM TFILES"

Set oRs = Server.CreateObject("ADODB.recordset")
Set oRs.ActiveConnection = oConn
oRs.Source = strSQL
oRs.LockType = 3
oRs.Open

' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then

' Add the current file in a DB field
' **********************************
oRs.AddNew
file.FileToField oRs.Fields("FILE")
oRs("FILENAME") = file.FileName
oRs.Update
intCount = intCount + 1
End If
Next

' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.<BR>")

fileCount = select count(filename) from TFiles

' Destruction
' ***********
oRs.Close
oConn.Close
Set oRs = Nothing
Set oConn = Nothing
%>

script download page: (scripts.asp)
-----------------------------------------------

<%
Dim folder, strslash, servername, scriptpath, thing, fdlm, fsize, physicalpath
folder = "scripts"

' The table shows the filename as a link, the date last modified and the file size
' Adjust the table and columns as needed. Delete columns if you don't need them

' Find out what type of server we are on and the server data
If Left(server.mappath("."),1) = "/" Then
strslash = "/"
Else
strslash = "\"
End If
servername = Request.Servervariables("server_name")
scriptpath = Request.Servervariables("script_name")
scriptpath = Mid(scriptpath,(Instrrev(scriptpath, "/")),1)
Dim filesobj, fileslist, fname, posnumright
dim f, dflm
Set filesobj = Server.CreateObject("scripting.filesystemobject")
Set fileslist = filesobj.GetFolder(server.mappath(".") & "/" & folder)
%>
<!-- ************* Table start and header row ****************-->
<br>
<center>
<table border="0" width="100%">
<tr><td align="center"><!--#include virtual="adrotator/adrotator_468x60.asp"--></td> <td><table border="0">
<tr><td valign="top"><font face="arial" size="1">If you would like to see the ad's on this web site removed, please donate!</font></td></tr>
<tr><th valign="top"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="snowboarderdude2003@hotmail.com">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="tax" value="0">
<input type="image" src="https://www.paypal.com/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form></th></tr>
</table></td></tr>
<tr><th><font size="6pt">SCRIPT ARCHIVE</font></th></tr>
<tr><td align="center" valign="top">
<table width="100%" border="1" style="border-collapse: collapse" bordercolor="white">
<tr>
<td width="50%" background="download_top.jpg">Script</td><td background="download_top.jpg">Date</td><td background="download_top.jpg" width="10%">Size</td><td background="download_top.jpg" width="15%">Downloaded</td></tr>

<%
For each thing In fileslist.files
posnumright = instrrev(thing, strslash)
fname = right(thing,(len(thing)-posnumright))
Set f = filesobj.GetFile(thing)
fdlm = f.datelastmodified
If f.size > 1023 Then
fsize = CStr(CInt(f.size / 1024)) & "K"
Else
fsize = CStr(f.size) & " bytes"
End If
physicalpath = server.mappath(".")
%>
<tr>
<td>
<!-- ******* First column with link to file name ******* -->
<img src="file.gif">&nbsp;<a href="http://<%=servername & scriptpath & folder & "/" & Server.HTMLEncode(fname) %>" target="_blank"><%=Server.HTMLEncode(fname)%></a>
</td>
<td>
<!-- ******* Second column with last modified date of file ***** -->
<%=Server.HTMLEncode(fdlm)%>
</td>
<td>
<!-- ******* Third column with file size ******** -->
<%= Server.HTMLEncode(fsize) %>
</td>
<td>
<!-- ******* Fourth column with # of times downloaded ******** -->

</td>
</tr>
<%
Set f = Nothing
Next
Set fileslist = Nothing
Set filesobj = Nothing
%>
<!-- *************** End of Table ****************** -->
</table>

The dl_screenshot.jpg is the download page. There are 2 more colums to the right (Size and Times Downloaded). I had to trim down the picture to 250px, grrrr. Made it look the best i could.
Attached Images
File Type: jpg dl_screenshot.jpg (8.4 KB, 3034 views)
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.

Last edited by Arctic; 08-18-03 at 06:25 PM.
Reply With Quote