Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2006, 11:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default forcing files to download problem

I am using the following code to force a file to download. The code works correctly if the file is less than about 4.5mb. It will not work if the file size is greater than that. Could the script be timing out or do servers have a limitation as to how big the file you can stream is?

strFileName = "SomeSongFile.mp3"
strFilePath = "C:fullpath\" & strFileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
 If objFSO.FileExists(strFilePath) Then

Set mp3File = objFSO.GetFile(strFilePath)
strFileSize = mp3File.Size

Set objFSO = Nothing
Set mp3File = Nothing

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8"
Response.ContentType = "application/x-unknown"

Response.BinaryWrite objStream.Read
Response.Flush

objStream.Close
Set objStream = Nothing

End If

Thank You
Mike
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old July 3rd, 2006, 08:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default

At the top of the page try

<%Server.ScriptTimeout = 5000 %>

Earl
www.jhdesigninc.com

 
Old July 4th, 2006, 09:45 AM
Authorized User
 
Join Date: Jun 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default

Just for clarification I forgot to include that this value can be adjusted upward to 10000 so if 5000 doesnt work for you you may want to bump it up.

Earl
www.jhdesigninc.com






Similar Threads
Thread Thread Starter Forum Replies Last Post
Download files from FTP dbellavi ASP.NET 1.0 and 1.1 Professional 7 July 19th, 2007 11:54 AM
How To Download Files sumith ASP.NET 1.0 and 1.1 Basics 2 June 22nd, 2007 12:45 AM
When will the working download files ... kmccloud BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 3 July 13th, 2006 11:06 AM
Forcing an ActiveX Version to download deepak.vasudevan HTML Code Clinic 0 September 2nd, 2005 02:19 AM
Download Files sriviggu2002 PHP How-To 1 March 17th, 2004 09:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.