473,598 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

More File download questions

I am trying to implment a file download via a link such that when clicked,
instead of starting the default application for that type of file the user
will be presented with a download dialog window. Well, thanks to Steve Orr,
I have that working. However, I still have a few issues. First, the
download dialog does not have the name of the file being downloaded in the
"File name" field, instead it has the name of the aspx page that have the
code to send the file to the client. Second, also in the download dialog,
the "File type" field has nothing in it. The code from my aspx page that is
doing the download is below. Is there ome other header that I can add that
will cause the download dialog to have the correct file name and file type
in it? Also, I'd liek to refresh the clling page so that the list of items
left to download nolonger includes the item just downloaded. If there
anyway to do that in this aspx page (adding a response.redire ct to the page
that the download link is on doesn't work). I tried adding and event handler
on the download page that refreshed when the link was clicked but it
refreshed before the download started. Thanks for any help you can provide.
<%@ Import Namespace="MyAs sembly" %>
<%@ Import Namespace="Syst em" %>
<%@ Import Namespace="Syst em.IO" %>
<%@ Import Namespace="Syst em.Xml" %>
<%
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''''''''''
Blah Blah Blah - just doing some validation at the
database''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '
''''''''''''''' '''''''''''

dim di as new DataInterface()
Dim gf as new genFuncs()
Dim doc As object
Dim FileName As String
Dim MyFileInfo As FileInfo
Dim StartPos, FileSize As Long
dim retval as string
dim funcRet as string
dim sessionid as string
dim errors as string
dim songid as integer
dim header as string
dim logid as int64
dim currentorder as string

sessionid = iif(request.que rystring("s")=n othing, "",
request.queryst ring("s"))
songid = cint(iif(reques t.querystring(" song")=nothing, "0",
request.queryst ring("song")))
logid = clng(iif(reques t.querystring(" log")=nothing, "-1",
request.queryst ring("log")))
currentorder = iif(request.que rystring("order ")=nothing, "",
request.queryst ring("order"))

funcRet = di.Connect(sess ionid)
if left(funcRet, 4) = "Fail" then
response.redire ct("welcome.asp x")
GoTo ExitPage
end if

doc = gf.loadXDoc(di. getValidateDown load(logid), errors)
if doc.DocumentEle ment.SelectSing leNode("//@status").inner Text = "fail"
then
response.redire ct("orderdownlo ad.aspx?s=" & sessionid & "&order=" &
currentorder)
goto exitpage
end if

doc = gf.loadXDoc(di. getSongInfo(son gid), errors)

Dim docRoot as XmlElement = doc.DocumentEle ment

FileName = di.songLocation & "\" & _

docRoot.SelectS ingleNode("//genreDirectory" ).innerText & "\" & _
docRoot.SelectS ingleNode("//labelID").inner Text &
"\" & _
docRoot.SelectS ingleNode("//songFile").inne rText
MyFileInfo = New FileInfo(FileNa me)
FileSize = MyFileInfo.Leng th

''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''''''''''
End database stuff
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '
''''''''''''''' '''''''''''''

''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''''''''''
Here's the important stuff
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '
'''''''''''
response.conten ttype = "audio/x-mpeg"
header = "attachment;fil ename=" & FileName
Response.AddHea der("Content-Disposition",he ader)
Response.WriteF ile(FileName, StartPos, FileSize)

''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''''''''''
End important stuff
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '
''''''''''''''' ''''''''''
retVal = di.updDownloade dSong(logid) 'marks the teh download record so
that this item can only be downloaded once.
ExitPage:
%>
Nov 17 '05 #1
0 1822

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3620
by: Ken | last post by:
How do I download files from the internet server to my computer? How do I tell the script the correct hard drive folder on my computer to copy the files to? After connecting to the internet server, I am trying: $_SESSION = "/uploaddir/"; // directory on server $_SESSION = "c:/_picture_file/"; // directory on computer
4
2970
by: Bernhard | last post by:
I am not sure if php can achieve this, but i guess that my problem shoulb be solved with an server side language. Is there any way i can tell if a visitor of my website has finished a download? For example the visitor clicks on a file download link, and when his download is finished then i want to happen something (for example some download counter or something like that.)
4
8909
by: dspohn | last post by:
I am designing a document management system (DMS). The files are stored in a directory on the webserver. The filenames for the documents are stored in a MySQL database. The DMS will track revisions from the initial version through the updates. We must have strict permissions set so only authorized personnel can access some documents. All of the documents when uploaded are given totally random names such as "114723fb5422c6bd5ed18f6.doc"....
2
1998
by: Tom Youngquist | last post by:
I am trying to download a text file that my .NET page has just created based on entered parameters on the web page. Everything seems to work and the file is created. I am using the following code to start the download process: Response.Clear() Response.ContentType = "text/plain" Response.AppendHeader("Content-Disposition", "attachment; filename=" & fileName) Response.AppendHeader("Content-Description", "This is your Cost Journal...
14
2177
by: Aaron | last post by:
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy protection). When a visitor clicks on the link I want them to see my_vacation_pic.jpg (fetch realname from database) is this possible with ASP.NET(C#)? Thanks Aaron
2
1832
by: John Spiegel | last post by:
Hi all, How does one allow a user to download a file WITH selecting where it should be downloaded to on their machine? Also, when using the WebClient.Download method, will the destination path written in Windows format (backslashes, etc.) translate across client platforms? Is there a better way? WebClient wc = new WebClient(); wc.DownloadFile(Server.MapPath(@"Downloads\MyFile.pdf"), @"C:\Temp\TheirFile.pdf");
7
3693
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again. The app I've written has three ASPX pages. One is a combined page which writes a little text...
3
2753
by: Nate Hekman | last post by:
I have an aspx page that generates a file on the fly for a person to download. It sends these http headers: Content-Type: text/plain Content-Disposition: attachment; filename="myfile.lic" The file being downloaded is a license file and MUST be stored with that ..lic extension. If I access this aspx page with IE, it prompts me if I want to open or save
5
2261
by: Bala | last post by:
Hi Is it possible to user can download the pdf files thru my webserver which the files are stored on different local machine on network. like my aspx page contain href links to those files. i tried and cannt be done. is it any other way to achive this? Thanks Bala
0
7896
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5848
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3896
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1503
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1246
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.