473,804 Members | 3,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download with dialog box with AJAX?

Hi,

on mouseclick I want to create a HTML on the server via PHP this file I
want to send to the client in a way that the user is prompted with a
"save as" dialog box.
I know how to do it "normally" (I use 'octet-stream') .. now I want to
do that with AJAX and do not succeed (the file is sent but no dialog
box).. what do I have to account for in AJAX case or is this not
possible in AJAX?

thx

pm

Nov 15 '06 #1
2 1716
VK

Petra Meier wrote:
Hi,

on mouseclick I want to create a HTML on the server via PHP this file I
want to send to the client in a way that the user is prompted with a
"save as" dialog box.
I know how to do it "normally" (I use 'octet-stream') .. now I want to
do that with AJAX and do not succeed (the file is sent but no dialog
box).. what do I have to account for in AJAX case or is this not
possible in AJAX?
In AJAX there is no file as such: there is responseText or responseXML
string you would need to write to file (which has to be created then).
So the question is if JavaScript can get an access to the local file
system. Within the standard security environment it can't.

Nov 15 '06 #2
Petra Meier a écrit :
Hi,

on mouseclick I want to create a HTML on the server via PHP this file I
want to send to the client in a way that the user is prompted with a
"save as" dialog box.
I know how to do it "normally" (I use 'octet-stream') .. now I want to
do that with AJAX and do not succeed (the file is sent but no dialog
box).. what do I have to account for in AJAX case or is this not
possible in AJAX?

thx

pm
Well, no it can't. Downloading a file from the server requires some
headers to be set, unfortunatly (or fortunatly), Javascript cannot
control headers sent by the server ; downloading a file is strictly a
browser behavior. But if you mean that you want your users to be able
to click a link and download a file without the entire page to be
refreshed, then you must use a hidden iframe (well, not hidden, but
with size of 0 by 0) and foreward the url into that iframe. Since the
parent browser will be the same window as your page's, a dialog box
will popup asking the user to save the file sent to the iframe.
Hope this helps.

-Yanick
-----------------------------------
Voodoo magic is bad.

Nov 16 '06 #3

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

Similar topics

2
1912
by: BillH | last post by:
I have an ASP page to download a CSV file using the following code Response.ContentType="text/plain Response.AddHeader "Content-disposition", "attachment; filename=Report.csv Response.Write strCS When I run this, I get the download dialog displayed twice. Any ideas how to solve this Thank
4
21956
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of play it without having to right-click and save. How can I force the browser to pop up the "save file as" dialog box instead of playing it? I know that I can encapsulate it in a zip file which will download and open WinZip. Thanks
3
2829
by: skyetech | last post by:
We're creating a file sharing area in our intranet. When a user clicks on a link they can save the file to their computer. When the file is done downloading and the 'File Download' dialog closes I want to update the database to flag that file as checked out. Because we don't want anyone else to download it until the file has been re-uploaded. Does anyone know how I can know when the dialog closes? It would also be good to know if the...
6
3093
by: JCO | last post by:
Does anybody have a Download Dialog written in JavaScripts? This is for a website. I've seen it done before.... where you click on what you want and the dialog comes up asking you if you want to save it. From what I can tell, the name of the file is passed as a parameter of the JavaScript. Below is an example of what somebody (who I don't know) has done: http://eteamz.active.com/tejanoswhite90girls/handouts/ Thanks
4
1448
by: ACaunter | last post by:
Hi, when the download dialog box opens and i click save or open or cancel.. everything works fine.. but then it's stuck in memory or something, because nomatter what button, listbox, combobox, etc.. i click on next.. that download dialog box keeps coming up... why is that??? -- AdamPC@hotmail.com
2
2098
by: Peter | last post by:
Hi! Please, could anybody advice me, is it possible to disable file download dialog in ASP.NET page or just save button in the file download dialog so that user should only open for example word document? Thanks Peter
5
12314
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
1
1760
by: sunita | last post by:
Hiii I open a file download dialog from a modal dialog...From the file download dialog i can either save or open the file.. Is there a way i can let the modal dialog that opens the file download dialog know whether the user has clicked on the open button or the save button of the file download dialog??
1
2297
by: RN1 | last post by:
In an ASP.NET app, users can upload their files to a remote server as back-up. I want to give users the provision to download files that they have uploaded to the remote server to their local machine. This is how I am invoking the file download dialog box that pops up in IE6 (users click a Button): Sub btn_DwnldFile(ByVal obj As Object, ByVal ea As EventArgs) Dim strURL As String = 'getting the file name Response.ContentType =...
3
5036
by: swand9 | last post by:
Hi, I need to downlad a server side generated csv file with Javascript. I need to send the login name and password and I don't want to use GET as I want to avoid a visible password in the URL. Further, my displayed HTML page should not reload. This is what I have tried: 1) Ajax: var link = "http://....."; var base = base64Encode("k320i:xxxxx");
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10327
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,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
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
5527
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
3
2999
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.