Date:  02/21/2006 07:25:47 AM Msg ID:  002845
From:  Ali Koumaiha Thread:  002845
Subject:  Corrupted file when downloading
I am using the example provided download.fwx, and i made minor modifications.  I am having 2 problems:
 
1- Files being downloaded are corrupted.  For example, if i have a small zip file 300K which opens prior to downloading, after it is downloaded via the method/code below, i cannot open the file again.  I tried it with XLS file, BMP file, JPG file, etc..
 
2- Files that are over 15MB will not download.  I have a file that is 20MB on a LAN (Basically my app is running on the lan), using the method below, the browser IE6 prompts for Save/Open.  When i click save, it acts as if its about to download, and after like 3 minutes or saw, i get a messagebox from IE "Server was reset or something like...etc.."
 
Do i have to put the files in a the root/accessible and just pass a link to the user?
 
I really want to use a script to do that.  What are my options.
 
thanks in advance.
 

<html>
<%
   cfile = request.item('cFile')
  
IF not empty(cfile)
 * A file was selected in the form
 Response.Buffer = .T.
 FileName = alltrim(cfile)
 FileExtension = UPPER(JustExt(FileName))
 * Verify that the file exists and is one of the authorized types
 IF FILE(FileName)
  * The content type must be changed in order to prevent browsers from displaying certain file types
  ContentType = "application/unknown"
  * Specify file name
  Response.AddHeader("Content-Disposition", "attachment; filename=" + cFile)
  
  * Read contents of file into string
  FileContent = ReadFile(FileName)
  * Specify size so that progress bar works properly
  Response.AddHeader("Content-Length", Server.ToString(LEN(FileContent)))
  Response.ContentType = ContentType
  Response.Buffer = .T.
  * Send file to browser
  Response.Write(FileContent)
  response.end
 ELSE
  response.write("Selected file does not exist, please contact IT Support")
  response.end
 ENDIF
ENDIF

Endfunc
%>
</html>