I am storing some the binary data for some files in a database (yes, I know this can be a bad idea). I am able to get the files out, with the correct content type, since I have stored it. But I'm having trouble getting the file to the client with the right filename. Right now I have the following code in a file called get_file.asp:
sSQL = "SELECT filename, contenttype, binarydata FROM new_attachment WHERE filename = '" & filename & "'"
oRs.Open sSQL, conn, 3, 3
If Not oRs.EOF Then
Response.ContentType = oRs(1)
Response.BinaryWrite oRs(2)
End if
This will return files correctly, but with the filename of 'get_file.asp', instead of, say, 'myfile.txt'. The url visited is .../get_file.asp?filename=myfile.txt
.
Is there a way I could change the name of the file when the browsers prompts the user to save it somewhere?