Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Wed, August 9, 2006 11:40 pm, Dave M G wrote: > Robert said: >> It's all about the headers... >> header( "Content-type: text/csv" ); This only forces a download if the browser has not been configured to do something special with text/csv application/octet-stream is the correct answer to force a download. >> header( "Content-disposition: inline; filename=$filename" ); This only works on some browsers, not all browsers. Unless you actually want to "fix" bug reports for the next 3 years on this page, with an ever-expanding list of headers that never quite work right: http://richardlynch.blogspot.com/ -- 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
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Wed, August 9, 2006 11:15 pm, Richard Lynch wrote: > On Wed, August 9, 2006 11:20 am, Dave M G wrote: >> How do I create a file that the user saves, and is not stored on the >> server? > > http://richadlynch.blogger.com Curses! Foiled again! Can't even type my own name :-v http://richardlynch.blogspot.com/ -- 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
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
Robert, Ray, Richard, Thank you all for responding with helpful advice. Robert said: It's all about the headers... header( "Content-type: text/csv" ); header( "Content-disposition: inline; filename=$filename" ); Ah... that's something I think I never would have figured out with the manual alone. Now that I know, it seems super easy. Thanks to everyone - those who responded directly as well as the PHP list in general. With the right regular expressions and file handling mechanisms in place, I now have a script that does everything I set out for it to do. Everyone's time and expertise is very much appreciated. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Wed, August 9, 2006 11:20 am, Dave M G wrote: > How do I create a file that the user saves, and is not stored on the > server? http://richadlynch.blogger.com -- 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
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Wednesday 09 August 2006 11:20, Dave M G wrote: > PHP List, > > In the last stage of my current script, I need to take a bunch of data > from the database and put it into a text file for the user to save to > their computer and import into an application. > > The file being created is just a list of Japanese words and definitions > delineated by tabs. > > The file format should be a text file. Actually, it could also be CSV > file, since it's tab delineated data. > > The application being imported to only accepts EUC-JP encoding for text > files that include Japanese text, so my data, which is stored in the > database as UTF-8, will need to be converted to EUC-JP at some point > along the way to being written to the file. > > This file need not ever be stored on the server. In fact, I'd rather it > not so as to avoid any headaches with permissions settings (which always > give me a headache, but that's a rant for another day). > > So, I'm looking on php.net for functions that would be able to create a > file out of some data and pass it along to the user. > > But it seems that the assumption of all the file functions (that I've > found) such as fwrite(), fopen(), file(), readfile(), and others are all > about taking an existing file and working with it. And more importantly, > all of them seem to assume that the place where the file would be stored > is on the servers system, and not immediately passed on to the user. > > I have a suspicion that this is one of those situations where the > starting point is assumed to be so simple that no one goes out of their > way to document or explain it. > > I'm too lost to know where to begin. > > How do I create a file that the user saves, and is not stored on the > server? > > -- > Dave M G For re-encoding to EUC-JP, I would check out the multibyte functions... specifically mb_convert_encoding: http://us2.php.net/manual/en/function.mb-convert-encoding.php HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Thu, 2006-08-10 at 01:20 +0900, Dave M G wrote: > PHP List, > > In the last stage of my current script, I need to take a bunch of data > from the database and put it into a text file for the user to save to > their computer and import into an application. > > The file being created is just a list of Japanese words and definitions > delineated by tabs. > > The file format should be a text file. Actually, it could also be CSV > file, since it's tab delineated data. > > The application being imported to only accepts EUC-JP encoding for text > files that include Japanese text, so my data, which is stored in the > database as UTF-8, will need to be converted to EUC-JP at some point > along the way to being written to the file. > > This file need not ever be stored on the server. In fact, I'd rather it > not so as to avoid any headaches with permissions settings (which always > give me a headache, but that's a rant for another day). > > So, I'm looking on php.net for functions that would be able to create a > file out of some data and pass it along to the user. > > But it seems that the assumption of all the file functions (that I've > found) such as fwrite(), fopen(), file(), readfile(), and others are all > about taking an existing file and working with it. And more importantly, > all of them seem to assume that the place where the file would be stored > is on the servers system, and not immediately passed on to the user. > > I have a suspicion that this is one of those situations where the > starting point is assumed to be so simple that no one goes out of their > way to document or explain it. > > I'm too lost to know where to begin. > > How do I create a file that the user saves, and is not stored on the server? It's all about the headers... I use the following: function uploadStream( $filename=null, $csv=null ) { if( $csv === null ) { $csv = $this->csv; } if( $filename === null ) { $filename = 'download.csv'; } header( "Content-type: text/csv" ); header( "Content-disposition: inline; filename=$filename" ); echo $csv; exit(); } You can feel free to adapt it since I ripped it out of my CSV writer service and so it won't work as-is. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Create an EUC-JP encoded file just for download, not to be kept on server
PHP List, In the last stage of my current script, I need to take a bunch of data from the database and put it into a text file for the user to save to their computer and import into an application. The file being created is just a list of Japanese words and definitions delineated by tabs. The file format should be a text file. Actually, it could also be CSV file, since it's tab delineated data. The application being imported to only accepts EUC-JP encoding for text files that include Japanese text, so my data, which is stored in the database as UTF-8, will need to be converted to EUC-JP at some point along the way to being written to the file. This file need not ever be stored on the server. In fact, I'd rather it not so as to avoid any headaches with permissions settings (which always give me a headache, but that's a rant for another day). So, I'm looking on php.net for functions that would be able to create a file out of some data and pass it along to the user. But it seems that the assumption of all the file functions (that I've found) such as fwrite(), fopen(), file(), readfile(), and others are all about taking an existing file and working with it. And more importantly, all of them seem to assume that the place where the file would be stored is on the servers system, and not immediately passed on to the user. I have a suspicion that this is one of those situations where the starting point is assumed to be so simple that no one goes out of their way to document or explain it. I'm too lost to know where to begin. How do I create a file that the user saves, and is not stored on the server? -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php