Apparently VFP cannot directly open files downloaded from the Internet even if you use the correct content type (Visual.FoxPro.Table). The error message returned by VFP is: "File access is denied."
The best solution is to force IE to save the results to a file and then open it manually. Please try the following code.
<% SELECT cust_no,cust_name,tel FROM customer INTO CURSOR results * Save the data to a temporary file
M.TempFileName = ADDBS(SYS(2023)) + SYS(3) + LTRIM(STR(Request.CurrentChannel)) + ".DBF" COPY TO (M.TempFileName) * Read the temp file
M.FileContent = FILETOSTR(M.TempFileName) DELETE FILE M.TempFileName M.FileName ="results.dbf" * Send the file to the browser
Response.Buffer = .T. Response.AddHeader("Content-Disposition", "attachment; filename=" + M.FileName) Response.AddHeader("Content-Length", Server.ToString(LEN(M.FileContent))) Response.ContentType = 'application/unknown' Response.Write(M.FileContent) %> |
Note this code will not work with DBF files with memo fields or index tags, because in such cases you will also need to download the FPT and/or CDX files. A good solution to avoid this problem is to compress all necessary files together in a single zip file before sending them to the browser.
FoxWeb Support Team
support@foxweb.com
Sent by angelin on 04/16/2002 01:32:11 AM:
I download dbf file use code as below:
select cust_no,cust_name,tel from customer into cursor results
copy to file/results.dbf
response.buffer = .t.
filename ="results.dbf"
fileextension = upper(justext(filename))
if file(filename) and fileextension == "DBF"
contenttype = "application/Microsoft Visual FoxPro"
response.addheader("content-disposition", "inline; filename=" +filename)
filecontent = readfile(filename)
response.addheader("content-length", server.tostring(len(filecontent)))
response.contenttype = contenttype
response.write(filecontent)
response.end
endif
every time I open the dbf file be downloaded ,the system always displays the message 'it's not a table'. I don't know how to solve it.please give me suggestion.
thanks.