Download file with aspSmartUpload without specifying content type

Im trying to setup something where the user clicks on a link, and then downloads a file.  The file can be any one of 15 differnt file types (.doc, .xls, etc).  Im using aspSmartUpload for the download, but the script hangs when I run it.  

Do I have to specify the content-type?  If so, is there a way I can automatically get it, like by looking at the file name, extension, etc?   Im not 100% sure of what my problem is, but I think I have to specify the content type in order to make the download work, unless I put the file in the web root (which I dont want to do)

also, once i do the download, is it possible to then redirect the user to a different screen?

      sItemFolderPath      = objRS("sItemFolderPath")
      sItemFileName      = objRS("sItemFileName")
      sFilePath            = "e:\inetpub\wwwroot\" & sItemFolderPath & sItemFileName
      Set MyUpload = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
      MyUpload.DownloadFile sFilePath
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hey here's a simple way of how to make a download file without the use of AspSmartUpload. So if you would like to do this, then can do it this way.

sItemFileName = "somefile.doc"
strFilePath = "e:\inetpub\wwwroot\" & sItemFolderPath & sItemFileName

Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename="& sItemFileName

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.LoadFromFile strFilePath

Response.BinaryWrite objStream.ReadText

Set objStream = Nothing

OR you can try this with the AspSmartUpload Component

sItemFolderPath     = objRS("sItemFolderPath")
sItemFileName     = objRS("sItemFileName")
sFilePath          = "e:\inetpub\wwwroot\" & sItemFolderPath & sItemFileName
Set MyUpload = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
MyUpload.DownloadFile sFilePath

Call mySmartUpload.DownloadFile(sFilePath, "application/octet-stream")


Just use  "application/octet-stream" for the ContentType.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sorry, I had a typo when i posted the last statement, try this for the second example thats above.


sItemFolderPath     = objRS("sItemFolderPath")
sItemFileName     = objRS("sItemFileName")
sFilePath          = "e:\inetpub\wwwroot\" & sItemFolderPath & sItemFileName
Set MyUpload = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
Call MyUpload.DownloadFile(sFilePath, "application/octet-stream")

you might want to try this too, worked for quite alot of pple:

my downloadFile.asp portion codes

    sItemFolderPath     = trim(objRS("sItemFolderPath"))
    sItemFileName     = trim(objRS("sItemFileName"))

    FPath = server.mapPath(sItemFolderPath&sItemFileName)
    Response.Buffer = True
    Response.ContentType = "application/asp-unknown"
    Response.AddHeader "content-disposition","attachment; filename=" & sItemFileName
    Set adoStream = Server.CreateObject("ADODB.Stream")
    adoStream.Type = 1
    Response.BinaryWrite adoStream.Read()
    adoStream.Close: Set adoStream = Nothing

 - Raymond
soBCAuthor Commented:
ah.  cool.  sorry howto, i ended up using the rocker...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.