Re: [PHP] Save page as text
On Wed, June 29, 2005 2:22 pm, [EMAIL PROTECTED] said: > I have page with PHP and Javascript code and I need to a link or bottun in > it to save its content to a plain text file. (I'm using an apache server > in a machine running Windows 2003, and I want to be able to use this > feature in IE 6 and Mozilla 1.7) > I saw some information about how to do that with PHP, but I wasn't able to > do it. > Can some one help me with that? Any browser that does *NOT* do a download with that, is a badly-broken browser indeed. There are a bunch of Microsoft-only types who recommend some "other" Content-type which just plain DOES NOT WORK on anything but IE. Surprised? Don't be. That's how Microsoft encourages incompatible software to retain market share. There are other headers you can send that some browser will use to choose the name of the file in the popup dialog where the user chooses to safe the download. These headers DO NOT WORK in *all* browsers, only some. If you want to be CERTAIN the download filename is what you want, then make sure your URL "looks" like a static URL to the filename you want. Specifically, convert a URL like: http://example.com/download.php?filename=whatever.xyz into: http://example.com/download/whatever.xyz You can do this by using .htaccess: ForceType application/x-httpd-php to "force" Apache to treat "download" as a PHP script, even though it has no .php in the filename. Within your "download" script (nee download.php) you can use: $_SERVER['PATHINFO']; to access "/whatever.xyz" and use *THAT instead of $_GET['filename'] to determine what file to download. I posted an include file some time ago that makes it easy to translate PATHINFO into an array $_PATH, which you treat pretty much like $_GET. The only caveat is that $_GET is a SuperGlobal and I can't make $_PATH be a SuperGlobal from within a PHP script. :-( Search this group for my name and PATHINFO and that script ought to turn up... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Save page as text
Hi, I have page with PHP and Javascript code and I need to a link or bottun in it to save its content to a plain text file. (I'm using an apache server in a machine running Windows 2003, and I want to be able to use this feature in IE 6 and Mozilla 1.7) I saw some information about how to do that with PHP, but I wasn't able to do it. Can some one help me with that? Thanks in advance, Rafael Magrin - Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora!
Re: [PHP] Save page
"Brandon Holtsclaw" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED] > try something like > > $handle = fopen ("http://www.pagetoget.com/thispage.html";, "rb"); > $contents = ""; > do { > $data = fread($handle, 1024); > if (strlen($data) == 0) { > break; > } > $contents .= $data; > } while(true); > fclose ($handle); > >From the PHP manual: // Another example, let's get a web page into a string. See also file_get_contents(). $html = implode ('', file ('http://www.example.com/')); > then you have all text from the .html page in $contents and you can do a > fwrite on it to a local file, echo it, str_rep etc etc etc > > Brandon Holtsclaw > [EMAIL PROTECTED] > > > - Original Message ----- > From: "Mike Mapsnac" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, May 10, 2004 10:37 AM > Subject: [PHP] Save page > > > > Hello > > > > I' m writing php script that will request page and save it locally. The > page > > URL will be parameter (example: http://www.pagetoget.com/thispage.html). > How > > php can request such page and save it locally on the file? > > > > Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save page
* Thus wrote Curt Zirzow ([EMAIL PROTECTED]): > * Thus wrote Mike Mapsnac ([EMAIL PROTECTED]): > > Hello > > > > I' m writing php script that will request page and save it locally. The > > page URL will be parameter (example: > > http://www.pagetoget.com/thispage.html). How php can request such page and > > save it locally on the file? > > $ch = curl_init(); > curl_setopt($ch, CURLOPT_FILE, '/path/to/output'); sorry that should be: $fp = fopen('/path/to/output', 'w'); curl_setopt($ch, CURLOPT_FILE, $fp ); Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save page
* Thus wrote Mike Mapsnac ([EMAIL PROTECTED]): > Hello > > I' m writing php script that will request page and save it locally. The > page URL will be parameter (example: > http://www.pagetoget.com/thispage.html). How php can request such page and > save it locally on the file? $ch = curl_init(); curl_setopt($ch, CURLOPT_FILE, '/path/to/output'); curl_setopt($ch, CURLOPT_URL, "http://www.pagetoget.com/thispage.html";); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save page
try something like $handle = fopen ("http://www.pagetoget.com/thispage.html";, "rb"); $contents = ""; do { $data = fread($handle, 1024); if (strlen($data) == 0) { break; } $contents .= $data; } while(true); fclose ($handle); then you have all text from the .html page in $contents and you can do a fwrite on it to a local file, echo it, str_rep etc etc etc Brandon Holtsclaw [EMAIL PROTECTED] - Original Message - From: "Mike Mapsnac" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, May 10, 2004 10:37 AM Subject: [PHP] Save page > Hello > > I' m writing php script that will request page and save it locally. The page > URL will be parameter (example: http://www.pagetoget.com/thispage.html). How > php can request such page and save it locally on the file? > > Thanks > > _ > Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! > http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/onm00200362ave/direct/01/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save page
I think you have to write apache rules to handle the request (search for ReWriteRule) and an index.php can save the file regards Mike Mapsnac wrote: Hello I' m writing php script that will request page and save it locally. The page URL will be parameter (example: http://www.pagetoget.com/thispage.html). How php can request such page and save it locally on the file? Thanks _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/onm00200362ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Save page
Hello I' m writing php script that will request page and save it locally. The page URL will be parameter (example: http://www.pagetoget.com/thispage.html). How php can request such page and save it locally on the file? Thanks _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/onm00200362ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] save page to DB
Hi all, I have a page that dynamically produces itself from a mysql db. It produces a form with the prices of scaffolding items and then uses JS as a quote calculator. I was wondering whether someone could tell me how to save the whole page into one field so that it can be reproduced in what ever state it was left? It will not ever be necessary for all the individual fields to be saved, only a few key totals will be eventually stored if a quote is finalised so I am looking for a quick way of storing the page if the quote is in progress and has to be left, Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php