Re: [PHP] Closing my Window after Download
Ave, Which page do you give this code in? For example, I have a page admin.php Therein is the link on which, when a user clicks, a window admin_dl.php opens. The admin_dl.php contains my force-download code and it is that window that I'm trying to close. If I specify this following code in admin.php itself, would it work? Admin.php does contain a lot of other stuff too. On 8/31/04 6:31 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: header(Content-Type: application/force-download); header(Content-Type: application/octet-stream); header(Content-Type: application/download); header(Content-Type: $mimetype); header(Content-Disposition: attachment; filename=filename.ext); header(Content-Transfer-Encoding: binary); header(Accept-Ranges: bytes); header(Content-Length: $filesize); $fo = fopen(/path/to/filename.ext,r); fpassthru($fo); fclose($fo); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
From: PHP Junkie [EMAIL PROTECTED] Which page do you give this code in? For example, I have a page admin.php Therein is the link on which, when a user clicks, a window admin_dl.php opens. The admin_dl.php contains my force-download code and it is that window that I'm trying to close. If I specify this following code in admin.php itself, would it work? Admin.php does contain a lot of other stuff too. Are we still on this topic? Say for example you request example.org/music.mp3. The file downloads to your computer, right? How is a request for a download of an MP3 file going to close your browser window? Your request for admin_dl.php is no different than a direct request for an MP3 file. You can't send a file and then expect to execute some HTML/JS or redirect to another page. Why are you opening another window, anyhow? Just link to admin_dl.php from admin.php. When a user clicks on the link, it'll trigger a download and the user will never leave admin.php. When you click on a link to an MP3, the web page your on doesn't change, does it? I thought this was already explained to everyone? If anyone thinks I'm wrong, I'm more than happy to admit it; just show me how. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, Oh My Gosh! You did it!! Gosh! I can't believe you solved it. And well, I don't know when this was explained to everyone but if you actually search the internet and try and lookup what I was trying to do, you'll find, as I found, a lot, and I mean a LOT of people with the exact same problem... Because everybody tries to window.open() the page with the force-download script. Yes your logic made sense to me as soon as I read it, and I had no doubts it will work. I almost said to myself how dumb could I be because it was such a simple logical issue. But unfortunately, trust me, it has NOT been explained to everyone. I even came across people who are using frames and some kind of JS to close to open window. I couldn't use that solution so I passed it. But anyhow, thanks a ton, I needed this real bad and now that I got it I feel stupid that I didn't make this sense myself. But then again, once in a while you need a hit on the head with a mallet just like this. Thank you so much. PHPJunkie. On 9/1/04 8:52 AM, John Holmes [EMAIL PROTECTED] wrote: From: PHP Junkie [EMAIL PROTECTED] Which page do you give this code in? For example, I have a page admin.php Therein is the link on which, when a user clicks, a window admin_dl.php opens. The admin_dl.php contains my force-download code and it is that window that I'm trying to close. If I specify this following code in admin.php itself, would it work? Admin.php does contain a lot of other stuff too. Are we still on this topic? Say for example you request example.org/music.mp3. The file downloads to your computer, right? How is a request for a download of an MP3 file going to close your browser window? Your request for admin_dl.php is no different than a direct request for an MP3 file. You can't send a file and then expect to execute some HTML/JS or redirect to another page. Why are you opening another window, anyhow? Just link to admin_dl.php from admin.php. When a user clicks on the link, it'll trigger a download and the user will never leave admin.php. When you click on a link to an MP3, the web page your on doesn't change, does it? I thought this was already explained to everyone? If anyone thinks I'm wrong, I'm more than happy to admit it; just show me how. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
From: PHP Junkie [EMAIL PROTECTED] But anyhow, thanks a ton, I needed this real bad and now that I got it I feel stupid that I didn't make this sense myself. But then again, once in a while you need a hit on the head with a mallet just like this. Well, someone did say the same thing as I did somewhere in this thread. Maybe I just explained it better or something. Either way... glad you're all straightened out or whatever. I really can't believe the thread went on as long as it did ;) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, I hear you... Even I feel it's a different problem but I don't know what. My first thought was that HTML or anything doesn't work after the Force-Download script in general But since you seem to use it, I guess it does. Now I don't know what to do, how to make it work. I can't understand what exactly is causing the problem. Thanks though. On 8/30/04 7:13 PM, Jasper Howard [EMAIL PROTECTED] wrote: if you're not getting any html after your php script, then there's a different problem. I do the same thing and all I use is: ?php ... ? script language=javascript !-- window.close(); //-- /script and I've never had a problem with it not closing... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, I didn't quite understand what you meant. The kind of files being saved by this script range from ZIP files to DBF files to JPG files etcetera. Where will the HTML be in those saved files? Any suggestions on what I need to do to make this work? On 8/30/04 8:31 PM, Curt Zirzow [EMAIL PROTECTED] wrote: * Thus wrote PHP Junkie: Ave, It still doesn't work. Not only that, I put up a close window button in the page and even that doesn't show up. Although that's still not what I want. What I want is the window to close automatically. Here's my page: ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? html head titleD/L Window/title script language=javascript function close_opener() Take a look at the end of the file you saved, you'll see your html there. Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
try this, after you force download of the file, use: header(Location: close_window_script.php); where the only code in that file is something like this: script language=javascript !-- window.close(); //-- /script this is a total workaround, but since its the only thing in the document, its very possible that it'll work, it won't take any more time to load either because you're using the header() function to forward, so the user has to download the same amount of info. -- -- Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ -- Php Junkie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ave, I hear you... Even I feel it's a different problem but I don't know what. My first thought was that HTML or anything doesn't work after the Force-Download script in general But since you seem to use it, I guess it does. Now I don't know what to do, how to make it work. I can't understand what exactly is causing the problem. Thanks though. On 8/30/04 7:13 PM, Jasper Howard [EMAIL PROTECTED] wrote: if you're not getting any html after your php script, then there's a different problem. I do the same thing and all I use is: ?php ... ? script language=javascript !-- window.close(); //-- /script and I've never had a problem with it not closing... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
* Thus wrote Jasper Howard: try this, after you force download of the file, use: header(Location: close_window_script.php); where the only code in that file is something like this: script language=javascript !-- window.close(); //-- /script this is a total workaround, but since its the only thing in the document, its very possible that it'll work, it won't take any more time to load either because you're using the header() function to forward, so the user has to download the same amount of info. This will *not* work. you can't send a file and close a window in the same request. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, Indeed, it didn't work. Anymore suggestions? On 8/31/04 2:09 PM, Jasper Howard [EMAIL PROTECTED] wrote: try this, after you force download of the file, use: header(Location: close_window_script.php); where the only code in that file is something like this: script language=javascript !-- window.close(); //-- /script this is a total workaround, but since its the only thing in the document, its very possible that it'll work, it won't take any more time to load either because you're using the header() function to forward, so the user has to download the same amount of info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
On Tue, 31 Aug 2004 16:56:18 -0400, PHP Junkie [EMAIL PROTECTED] wrote: Indeed, it didn't work. Anymore suggestions? I've got a couple of ideas, but I really think you're making life too hard for yourself. You might want to rethink what you're trying to do rather than creating a clunky solution. Anyways, on with my ideas... * Send the file as the first part of a multipart response. The second part would be an HTML page which uses Javascript to close the window. I have no idea if this would work. * I'm guessing the window you want to close was created by the main window. If this is the case you could use Javascript to start the file downloading in the main window from the popup and then close the popup. e.g. opener.location.href = 'thedownload.file'; window.close();. This should work. -- Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, It still doesn't work. Not only that, I put up a close window button in the page and even that doesn't show up. Although that's still not what I want. What I want is the window to close automatically. Here's my page: ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? html head titleD/L Window/title script language=javascript function close_opener() { parentwin = window.self; // Make handle for current window named parentwin parentwin.opener = window.self;// Tell current window that it opened itself parentwin.close(); // Close window's parent (e.g. the current window) } /script /head body onLoad=close_opener(); centerforminput type=button value=Close Window onClick=window.close();/form/center /body /html I don't know what to do... The page just won't close. Here, try this JS: function close_opener() { parentwin = window.self; // Make handle for current window named parentwin parentwin.opener = window.self;// Tell current window that it opened itself parentwin.close(); // Close window's parent (e.g. the current window) } HTH - Miles Thompson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
if you're not getting any html after your php script, then there's a different problem. I do the same thing and all I use is: ?php ... ? script language=javascript !-- window.close(); //-- /script and I've never had a problem with it not closing... -- -- Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ -- Php Junkie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ave, It still doesn't work. Not only that, I put up a close window button in the page and even that doesn't show up. Although that's still not what I want. What I want is the window to close automatically. Here's my page: ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? html head titleD/L Window/title script language=javascript function close_opener() { parentwin = window.self; // Make handle for current window named parentwin parentwin.opener = window.self;// Tell current window that it opened itself parentwin.close(); // Close window's parent (e.g. the current window) } /script /head body onLoad=close_opener(); centerforminput type=button value=Close Window onClick=window.close();/form/center /body /html I don't know what to do... The page just won't close. Here, try this JS: function close_opener() { parentwin = window.self; // Make handle for current window named parentwin parentwin.opener = window.self;// Tell current window that it opened itself parentwin.close(); // Close window's parent (e.g. the current window) } HTH - Miles Thompson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
* Thus wrote PHP Junkie: Ave, It still doesn't work. Not only that, I put up a close window button in the page and even that doesn't show up. Although that's still not what I want. What I want is the window to close automatically. Here's my page: ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? html head titleD/L Window/title script language=javascript function close_opener() Take a look at the end of the file you saved, you'll see your html there. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, Trust me John, I would not post here without trying out many javascript functions first. In fact, the reason I posted here is because I began to think that a PHP script like that won't allow the window to close, because from window.close() to self.close() to various Timeout Close scripts, I've tried many javascript functions. I don't get any errors ... The window just doesn't close... On 8/24/04 2:09 PM, John Nichel [EMAIL PROTECTED] wrote: PHP Junkie wrote: Ave, The browser window which launched the Save As window... PHP cannot do this. You'll have to use JavaScript in the browser window. Something like ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? script language=JavaScript window.close(); /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
At 09:14 AM 8/26/2004, PHP Junkie wrote: Ave, Trust me John, I would not post here without trying out many javascript functions first. In fact, the reason I posted here is because I began to think that a PHP script like that won't allow the window to close, because from window.close() to self.close() to various Timeout Close scripts, I've tried many javascript functions. I don't get any errors ... The window just doesn't close... On 8/24/04 2:09 PM, John Nichel [EMAIL PROTECTED] wrote: PHP Junkie wrote: Ave, The browser window which launched the Save As window... PHP cannot do this. You'll have to use JavaScript in the browser window. Something like ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? script language=JavaScript window.close(); /script Here, try this JS: function close_opener() { parentwin = window.self; // Make handle for current window named parentwin parentwin.opener = window.self;// Tell current window that it opened itself parentwin.close(); // Close window's parent (e.g. the current window) } HTH - Miles Thompson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
From: PHP Junkie [EMAIL PROTECTED] Anyone's got any tips for me? Find a JavaScript list? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
PHP Junkie wrote: Ave, I use the PHP Header directives to create a page which would force-download the file for the user... ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? What I want is to have this window close automatically once it's launched the Save As Dialog Box ... I tried several javascript window.close(), self.close() functions but none of them seem to work. The window wont close. It remains open. You wish to close which window? The Save As window, or the browser window which launched the Save As window? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
Ave, The browser window which launched the Save As window... On 8/24/04 1:41 PM, John Nichel [EMAIL PROTECTED] wrote: PHP Junkie wrote: Ave, I use the PHP Header directives to create a page which would force-download the file for the user... ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? What I want is to have this window close automatically once it's launched the Save As Dialog Box ... I tried several javascript window.close(), self.close() functions but none of them seem to work. The window wont close. It remains open. You wish to close which window? The Save As window, or the browser window which launched the Save As window? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
PHP Junkie wrote: Ave, The browser window which launched the Save As window... PHP cannot do this. You'll have to use JavaScript in the browser window. Something like ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? script language=JavaScript window.close(); /script -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php