Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download files

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
0
0
NL
I have tried two things in regards to get files downloaded from my web server but none has worked. I hope somebody can kick me in the right direction.

I have tried this, which download the files but when I open the files the file will not open. The format is not recognized.

<%
Dim varFiles
Dim ArrFiles
Dim i

varFiles = request.QueryString("downloadfiles")

Response.ContentType = "application/x-unknown" ' arbitrary

if instr(varFiles,",") > 0 then

ArrFiles = split(varFiles,",")

for i = 0 to ubound(ArrFiles)
Response.AddHeader "Content-Disposition","attachment;filename=" & ArrFiles(0)
Next
Else
Response.AddHeader "Content-Disposition","attachment;filename=" & varFiles
end if
%>

The one below here says that the file does not exsist, where the path looks fine:

Function ShowFolderList()
Dim folderspec, fso, folder, foldercollection, file, tmp
folderspec = Server.mapPath("\demotaskMngtupload\UploadFolder")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(folderspec)
Set foldercollection = folder.Files
For Each file in foldercollection
tmp = tmp & "<a href='\demotaskMngtupload\UploadFolder/" & file.name & "'>" & file.name & "</A><BR>"
Next
ShowFolderList = tmp
End Function
response.write showfolderlist()
 
if you add the line
Code:
response.Write folderspec
response.write
after
Code:
folderspec = Server.mapPath("\demotaskMngtupload\UploadFolder")

you can see the fysical folder that the script is searching... and most likely that is wrong



 
typo!

Code:
response.Write folderspec
response.end

of course
 
The path is correct, if I put the path on our web server then it will open up that folder
 
I might need to upload this code to a provider where I will not have any permissions.

Is my cause lost ?
 
There are backslash and forward-slash. The inconsistent use of them looks horrid, though it may not necessarily lead to the error!
 
true, I changes it and still its the same

Would I need to look into binary download ?
 
okay.. I found this :

Response.AddHeader "Content-Disposition","attachment;filename=" & varFiles

Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(varFiles)
Response.BinaryWrite adoStream.Read()

This will download the file, my next problem is that with IE the path in the save as is the full string and not just the file name :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top