Hey everyone, I've got a few files I wanted available for download for my friends site. And for some reason I can't get it to download once I click on the link? <a href="brochures.rar" target="_blank">Download Brochures</a></div> Everytime i click on the download brochures link, the browser opens the file and its a bunch of code and symbols. I just want a pop up just like every other downloadable file on the net. Any help would be appreciated.
It may be set to automatically open in your browser. If you are using Firefox, look in Tools->Options->Applications for the WinRAR content types. Or you can select a RAR file in Windows Explorer, right click and pick Open With->Choose Program, and then uncheck the "Always open..." box.
What exactly do you mean that the content type header may be being sent incorrectly, - how to fix this issue if indeed it is the issue. Thanks.
well - how come other websites that have rar files available for download come up with a pop up download box when i download them but the one on the site im working on doesn't? Something wrong with my code?
In that case, the server is probably at fault. Did you try removing target="_blank"? It didn't cause a problem in my browser, but you might be using something different.
well, since you didnt give a link, this is general info. if your site is a php site, then you can create a php file and add: <?php header('Content-disposition: attachment; filename=filename.rar'); header('Content-type: octet-stream); readfile('filename.rar'); ?> for example. this will force the download of the file ( please read more about content-types to apply it to your situation) if your link is a simple html link, you can use javascript to force download it: <a href="javascript:void(0);" onclick="document.execCommand('SaveAs',true,'filename.rar');" >Download</a> if it is .net then create a download.aspx file and add this (VB EXAMPLE) <%@ Page language="vb" runat="server" explicit="true" strict="true" %> <script language="vb" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring If strRequest <> "" Then 'get absolute path of the file Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server If file.Exists Then 'set appropriate headers Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) Response.AddHeader("Content-Length", file.Length.ToString()) Response.ContentType = "application/octet-stream" Response.WriteFile(file.FullName) Response.End 'if file does not exist Else Response.Write("This file does not exist.") End If 'nothing in the URL as HTTP GET Else Response.Write("Please provide a file to download.") End If End Sub </script> hope that helps... next time, please give example and link