Results 1 to 8 of 8

Thread: VBScript Response.BinaryWrite problem

  1. #1
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom

    VBScript Response.BinaryWrite problem

    Trying to use the BinaryWrite method of the VBScript Response object and for some reason anything above 1Mb just refuses to download.

    Anything less than 1Mb and the download button press would result in an instant 'Open, Save, Cancel' pop up, anything larger and it would bring up a 'File Download - Getting File Info progress bar pop up' which hangs for several minutes (but less than the 10 minutes specified by the Response.Timeout method) and then up pops an error saying that it couldn't download the page from which the code was called. Which is odd, since I don't want to download the page, just the file I've requested.

    Anybody know of a quick fix? If it's a server issue then I'm screwed, 'cause it'd remote hosting.
    sig removed by Zak33

  2. #2
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,782
    Thanks
    23
    Thanked
    42 times in 25 posts
    I know with ASP.NET there is a default limit for the amount of data you can send to the server, i.e. uploading a file. There may be a similar thing for ASP but I've never come across it. Check that your loops aren't getting stuck at 1024 itterations. Can you post your code?
    Simon


  3. #3
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    Response.Buffer = true
    Response.Expires = 10
    Response.Clear()

    Dim p_strFileName
    Dim strFileName
    Dim strCustomerDirectory
    Dim strUploadDirectory

    p_strFileName = Request.Form("filename")
    strCustomerDirectory = Request.Form("CustomerDirectory")
    strUploadDirectory = Request.Form("uploaddir")
    strFileName = Server.Mappath("..\..\database\APRDocSub\" & strCustomerDirectory & "\" & strUploadDirectory & "\" & p_strFileName)

    Dim objStream

    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open()

    objStream.Type = 1

    Dim objFSO
    Set objFSO = server.CreateObject("Scripting.FileSystemObject")

    Dim FileName
    Set FileName = objFSO.GetFile(strFileName)


    Dim intFileLength
    intFileLength = FileName.Size
    Dim FileSize
    FileSize = FileName.Size

    objStream.LoadFromFile(strFileName)

    Response.AddHeader "Content-Disposition", "attachment; filename=" & p_strFileName
    'Response.AddHeader "Content-Length", intFilelength
    Response.CharSet = "UTF-8"
    Response.ContentType = "application/octet-stream"

    ' output the file to the browser
    Response.BinaryWrite(objStream.Read)

    Response.Flush()

    ' tidy up
    objStream.Close()
    objStream = null


    That's all he wrote

    I use a 3rd party component for upload (ASPUpload by Persit Software) so no probs at that end, but download is causing a different problem...as you can see
    sig removed by Zak33

  4. #4
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,782
    Thanks
    23
    Thanked
    42 times in 25 posts
    Can't see anything obviously wrong with that, though I've not used ASP for a while now. Try this:

    Code:
    <%
    	'bigdownload.asp - download of files with size up to 2GB
    	'Sample for ScriptUtils.ByteArray
    	'c2003, http://www.motobit.com
    
    	SendFileByBlocks "F:\work\WebLib.dll", 65535
    
    	Sub SendFileByBlocks(FileName, BlockSize)
    		Dim FileSize, ByteCounter
    		FileSize = CreateObject("scripting.filesystemobject").GetFile(FileName).Size
    
    		'Switch off buffer.
    		Response.Buffer = False
    
    		'This is download
    		Response.ContentType = "application/x-msdownload"
    
    		'Set file name
    		Response.AddHeader "Content-Disposition", _
    		  "attachment; filename=""" & GetFileName(FileName) & """"
    
    		'Set Content-Length (ASP doen not set it when Buffer = False)
    		Response.AddHeader "Content-Length", FileSize
    		'Response.CacheControl = "no-cache"
    
    		Dim BA
    		Set BA = CreateObject("ScriptUtils.ByteArray")
    
    		'Loop through file contents.
    		For ByteCounter = 1 To FileSize Step BlockSize
    			'Do not write data when client is disconnected
    			If Not Response.IsClientConnected() Then Exit For
    
    			'Read block of data from a file
    			BA.ReadFrom FileName, ByteCounter, BlockSize
    
    			'Write the block to output.
    			Response.BinaryWrite BA.ByteArray
    		Next
    		
    	End Sub
    
    
    	Function GetFileName(FullPath)
    		Dim Pos, PosF
    		PosF = 0
    		For Pos = Len(FullPath) To 1 Step -1
    			Select Case Mid(FullPath, Pos, 1)
    				Case ":", "/", "\": PosF = Pos + 1: Pos = 0
    			End Select
    		Next
    		If PosF = 0 Then PosF = 1
    		GetFileName = Mid(FullPath, PosF)
    	End Function
    %>
    Simon


  5. #5
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    Shad ... cheers for the help. much appreciated. However, turns the limiting factor was a server side setting which had been accidently put to 1 instead of 10 MB...silly blighters...
    sig removed by Zak33

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by ibm
    Shad ... cheers for the help. much appreciated. However, turns the limiting factor was a server side setting which had been accidently put to 1 instead of 10 MB...silly blighters...
    Hello IBM

    I've got exactly the same problem with my code ! Could you tell me what server side setting you changed. My browser's progress bar hangs on Response.AddHeader "Content-Length", objFile.Size with a 6.5MB file (installer download).

    I would appreciate any help you aor anyone else can give.

  7. #7
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    Sorry mate, wish I could help, but it was my hosting support who figured out which setting needed correcting. Who are you hosting with?
    sig removed by Zak33

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by ibm
    Sorry mate, wish I could help, but it was my hosting support who figured out which setting needed correcting. Who are you hosting with?
    I sorted it out now.

    It was the AspBufferingLimit setting in \Windows\System32\inetserv\Metabase.xml needed changing from its default value of 4194304 to a higher value.

    Thanks for your reply.

    Nick Rosenberg

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. DVI problem, pc won't start! help needed.
    By snowwolf in forum Graphics Cards
    Replies: 1
    Last Post: 09-04-2010, 04:11 PM
  2. Very stange problem!
    By gobby in forum Help! Quick Relief From Tech Headaches
    Replies: 2
    Last Post: 28-08-2004, 05:20 PM
  3. Troubleshooting - Software & Driver problems
    By Steve in forum Help! Quick Relief From Tech Headaches
    Replies: 0
    Last Post: 09-07-2004, 06:30 PM
  4. power problem??
    By Spud1 in forum Help! Quick Relief From Tech Headaches
    Replies: 4
    Last Post: 08-06-2004, 06:28 AM
  5. Wierd Ati driver problem
    By Skii in forum PC Hardware and Components
    Replies: 5
    Last Post: 20-01-2004, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •