navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Free FrontPage Templates

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

How do I make files downloadable

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> How do I make files downloadable
Page: [1]
 
TTTTT

 

Posts: 66
Joined: 10/14/2004
Status: offline

 
How do I make files downloadable - 10/14/2004 13:20:20   
Hi, this is my first post so sorry if I'm doing anything wrong.

I'm trying to make files downloadable from my website (which is not online yet).

I'm using frontpage 2003 and most of the files are either pdf or compressed avi.

If possible could you tell how I would make these files downloadable, although I assume with the pdf that the file wouldn't have to be downloaded but it would just need a link to it?


With the avi files I need it to be a sort of click on the name and then it asks you to download the file.



Thanks for the help
dpf

 

Posts: 7126
Joined: 11/12/2003
From: India-napolis
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 13:30:32   
simply load the file to your server and on your page..."click here to download my file " and link that text to the file..its that simple

_____________________________

Dan

(in reply to TTTTT)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 13:40:13   
if simply linking to them doesn't do what you want, try placing the files in a .zip directory and then link to that...

In some cases you won't be prompted for a download...

A PDF is going to open in Acrobat, and can be saved from there, but it's not really downloaded at that point...

And a movie may try to stream rather than download if you just link to it.

Try it out, and if it doesn't work, zip them.


_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to dpf)
TTTTT

 

Posts: 66
Joined: 10/14/2004
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 14:13:33   
Thanks a lot
I want to try out both ways so I can see which one i preffer.

But... I dont really know how to put something in a .zip directory.

Any chance you could explain in more detail.

I dont quite understand what you mean about acrobat, do you recommend I put them in a .zip directory aswell?

(in reply to bobby)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 14:41:41   
If you're on Windows XP simply right click the file, select Send To > Compressed folder

That will do it...

If you're on a previous Windows version you may need to download an application to create the zip file... like Winzip or one of the others available.

PDF documents, when you link to them, will typically open in Adobe Acrobat Reader (if the visitor has it installed)

That's the free tool from Adobe used to view .pdf documents.

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to TTTTT)
Charles W Davis

 

Posts: 1725
Joined: 3/7/2002
From: Henderson Nevada USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 14:44:16   
A ZIP folder is created with a program like WinZIP. It compresses the file to reduce file size thereby reducing time to upload and download. It is available at: http://www.winzip.com/

Adobe Acrobat is a program that creates .pdf files. It is available at: http://www.adobe.com/products/acrobatpro/main.html
An evaluation alternative is Win2PDF available from: http://www.daneprairie.com/products/win2pdf.htm

PDF files are read by using the free Adobe Reader. Available here: http://www.adobe.com/products/acrobat/readstep2.html

_____________________________

Enjoy! It' s your endeavor!
http://www.anthemwebs.com

(in reply to TTTTT)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 14:47:52   
quote:

do you recommend I put them in a .zip directory aswell?
Only if you want them to be strictly downloadable...

When opened in Acrobat Reader the visitor should have the option to "Save As" from the File menu.

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Charles W Davis)
TTTTT

 

Posts: 66
Joined: 10/14/2004
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 14:50:37   
Thank you all again

If I have any other problems while creating my website ill come back here

PLUS

I just tried to use thezip folder method,

I'm using a page template with a title and links and main page,

When I click on the link to alf.zip it gets a screen inside the screen which looks like windows explorer.

The other method seems to work ok I think I 'll use that

(in reply to bobby)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 15:04:45   
Is this when on your local computer or uploaded to the server?

A .zip file shouldn't be viewable from the web...?


_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to TTTTT)
TTTTT

 

Posts: 66
Joined: 10/14/2004
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 16:57:08   
The website is in no way online or uploaded to a server

I just click on the preview in internet explorer button

(in reply to bobby)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/14/2004 17:10:01   
Aha...

Once you publish to a server the .zip files will not "open" like they are on your local machine... they will prompt a download.

:)

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to TTTTT)
TTTTT

 

Posts: 66
Joined: 10/14/2004
Status: offline

 
RE: How do I make files downloadable - 10/15/2004 2:50:16   
SO would it be better for me to make the .zip files downloadable rather than just a link to the file?

(in reply to bobby)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/15/2004 10:11:10   
Only if linking to the file directly doesn't prompt for a download the way you expect it to..


_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to TTTTT)
d a v e

 

Posts: 4179
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: How do I make files downloadable - 10/15/2004 11:19:40   
IMO it's better to just link directly to the file and let users left click and open/be prompted for an action or right click and save it, though a zip file may also be a good option.

_____________________________

David Prescott
Gekko web design

(in reply to bobby)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: How do I make files downloadable - 10/15/2004 11:26:03   
That's the idea behind the .zip files.

PDF's will try to open in Acrobat Reader (or equivelant) and movies will probably try to stream rather than download to the HDD.

Both can be avoided by zipping the files... since a zip file can't be opened remotely by the browser, it prompts the download dialog you described.

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to d a v e)
d a v e

 

Posts: 4179
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: How do I make files downloadable - 10/15/2004 12:02:27   
of course it depends which browser you're using - i'm forgetting how that other browser works (IE) ;)

_____________________________

David Prescott
Gekko web design

(in reply to bobby)
jeepless

 

Posts: 226
Joined: 12/20/2003
From: Smack in the middle of USA
Status: offline

 
RE: How do I make files downloadable - 10/16/2004 12:13:27   
How do I make files downloadable?

Since I see this question a lot, I offer the following two asp scripts that I discovered some time ago (I don't remember where). I've used them since with absolutely no problems, and with a little tweaking (if it's even necessary), you should be able to make them work for you. These scripts will force the download prompt to appear instead of opening the file in the browser, but only when the content-type is pre-defined in the second script. Undefined content-types will still open in the browser.

The first script will list all files available for dowload by searching the folder where they are stored:


First, create a new page and give it an .asp extension.
Then design the page how you want it to look (ie, add tables, text, graphics, etc.).
Other than the .asp extension, you can name this page whatever you like.

Then within the html code, add the following to the very top of your page (before the opening html tag):

<%
	Dim strThisPage
	strThisPage = Request.ServerVariables("SCRIPT_NAME")
	strThisPage = Right(strThisPage, Len(strThisPage) - 1)

	'****************************************************
	' Add the path to the folder that holds your files in the next statement.
	'****************************************************

	Dim FILE_FOLDER
	'Add the path to the folder that holds your files here
	FILE_FOLDER = Server.MapPath("./yourfilefolder/") '<----
%>



Now add the following into your html code where you want the actual file names listed (eg, in a table cell):

<%
	GetAllFiles
%>



Add the following to the very end of your html code (after the closing html tag):

<%
Sub GetAllFiles()
	Dim oFS, oFolder, oFile
	Set oFS = Server.CreateObject("Scripting.FileSystemObject")

	'Set Folder Object To Proper File Directory
	Set oFolder = oFS.getFolder(FILE_FOLDER)

	Dim intCounter
	Dim FileArray()

	intCounter = 0
	ReDim Preserve FileArray(oFolder.Files.Count, 4)

	For Each oFile in oFolder.Files
		strFileName = oFile.Name
		strFileType = oFile.Type
		strFileSize = oFile.Size
		strFilePath = oFile.Path
		strFileDtMod = oFile.DateLastModified

		FileArray(intCounter, 0) = strFileName
		FileArray(intCounter, 1) = "<A class=File HREF=" & Chr(34) & "startDownload.asp?File=" _
			& strFilePath & "&Name=" & strFileName & "&Size=" & strFileSize & Chr(34) _
			& " onMouseOver=" & Chr(34) & "self.status='" & strFileName & "'; return true;" & Chr(34) _
			& " onMouseOut=" & Chr(34) & "self.status=''; return true;" & Chr(34) & ">" & strFileName & "</A>"
		FileArray(intCounter, 2) = strFileType
		FileArray(intCounter, 3) = strFileSize
		'FileArray(intCounter, 4) = strFilePath
		FileArray(intCounter, 4) = strFileDtMod

		intCounter = (intCounter + 1)
	Next

	' EchoB("<B>" & oFolder.Files.Count & " Files Available for Download</B>")

	intRows = uBound(FileArray, 1)
	intCols = uBound(FileArray, 2)

	For x = 0 To intRows -1
		Echo("<TR>")
		For z = 0 To intCols
			If z > 0  Then
				BuildTableCol(FileArray(x, z))
			End IF
		Next
		Echo("</TR>")
	Next


	Cleanup oFile
	Cleanup oFolder
	Cleanup oFS
End Sub

Function Echo(str)
	Echo = Response.Write(str & vbCrLf)
End Function

Function EchoB(str)
	EchoB = Response.Write(str & "<BR>" & vbCrLf)
End Function

Sub Cleanup(obj)
	IF isObject(obj) Then
		Set obj = Nothing
	End IF
End Sub

Function StripFileName(strFile)
	StripFileName = Left(strFile, inStrRev(strFile, "\"))
End Function

Sub BuildTableCol(strData)
	Echo("<TD CLASS=DataCol>" & strData & "</TD>")
End Sub

'Not implemented
Sub BuildTableRow(arrData)
	Dim intCols
	intCols = uBound(arrData)
	For y = 0 To intCols
		Echo("<TD CLASS=DataCol>" & arrData(y) & "</TD>")
	Next
End Sub
%>


Finally, save this page and link to it from your other pages.



The second script will force the file to dowload and prompt the user to save the file to their hard drive. It MUST be used in conjunction with the first script:


Save the following code as a new .asp page and name it "startDownload.asp".

<%
	'****************************************************
	' This page forces the 'save as file' prompt to prevent files from being opened in the browser.
	' It MUST be saved as "startDownload.asp" to work with the first script.
	'****************************************************

Response.Buffer = True
Dim strFilePath, strFileSize, strFileName

Const adTypeBinary = 1

strFilePath = Request.QueryString("File")
strFileSize = Request.QueryString("Size")
strFileName = Request.QueryString("Name")

Response.Clear

'*******************************
' Requires MDAC 2.5 to be stable
' I recommend MDAC 2.6 or 2.7
'*******************************
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

strFileType = lcase(Right(strFileName, 4))
    
	' Feel Free to Add Your Own Content-Types Here
    Select Case strFileType
	Case ".asf"
	ContentType = "video/x-ms-asf"
	Case ".avi"
	ContentType = "video/avi"
	Case ".doc"
	ContentType = "application/msword"
	Case ".zip"
	ContentType = "application/zip"
	Case ".xls"
	ContentType = "application/vnd.ms-excel"
	Case ".gif"
	ContentType = "image/gif"
	Case ".jpg", "jpeg"
	ContentType = "image/jpeg"
	Case ".wav"
	ContentType = "audio/wav"
	Case ".mp3"
	ContentType = "audio/mpeg3"
	Case ".mpg", "mpeg"
	ContentType = "video/mpeg"
	Case ".rtf"
	ContentType = "application/rtf"
	Case ".htm", "html"
	ContentType = "text/html"
	Case ".asp"
	ContentType = "text/asp"
	Case Else
	'Handle All Other Files
	ContentType = "application/octet-stream"
    End Select
	
	Response.AddHeader "Content-Disposition", "attachment; filename=000" & strFileName
	Response.AddHeader "Content-Length", strFileSize
	' In a Perfect World, Your Client would also have UTF-8 as the default in their browser
	Response.Charset = "UTF-8"
	Response.ContentType = ContentType
	
	Response.BinaryWrite objStream.Read
	Response.Flush

objStream.Close
Set objStream = Nothing

%>



For these two scripts to work properly they must be stored in the same file folder. The first script can be embedded in any page you like using any file name you prefer (eg, myfiles.asp). The second script MUST be saved as "startDownload.asp" since the first script specifically calls that page. Then just link to the page that contains the first script (eg, "myfiles.asp) from your other web pages. When the first page (eg, "myfiles.asp") is accessed, the script will display and sort the files in alphabetical order. When a file name on this page is clicked, the browser will open the "save as file" prompt. That's it!

You can see the scripts in action by going here: Download Page

I can offer some limited help to get these scripts to work for you, if needed. I'm not an asp guru, but I've tinkered with these two scripts enough to make them work in multiple situations.

Cheers!




(in reply to TTTTT)
Andraw

 

Posts: 13
Joined: 1/16/2005
Status: offline

 
RE: How do I make files downloadable - 1/17/2005 11:16:19   
Hi, jeepless,
Your source codes for downloading file is very helpful, thank you very much.
I have a question, if I don't want a link, instead, I want to use a button, when use click the button, the download dialog box appear, how can I do it? Please give me some instruction.
when I use links: in startDownload.asp file, the querystring variable are:

File: C:\Inetpub\wwwroot\test\DownloadAbleFile\reportWord1.doc
size: 24064
name: reportWord1.doc

But when I use button, they are:
File: C:InetpubwwwrootestDownloadAbleFileeportWord1.doc
size: 24064
name: reportWord1.doc

the backslash is gone, why???????

Andraw


(in reply to jeepless)
Page:   [1]

All Forums >> Web Development >> General Web Development >> How do I make files downloadable
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts