Re: [PHP] Creating a File in Memory

2007-09-08 Thread Per Jessen
John Schattel wrote:

 lacks a file name.  So when a program like Google Earth tries to
 process the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip,
 the file has no name but can otherwise be extracted just fine.  Once
 extracted, Google Earth can process the file.  Does anyone know how I
 might add the file name information to the ndfdViaPipe.kmz? 

Add some headers before you send the file:

header(Content-Type: application/octet-stream);
header(Content-Disposition: attachment; filename=\blah.zip\);


/Per Jessen, Zürich

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Creating a File in Memory

2007-09-07 Thread John Schattel

Hello All,

I am trying to zip data in a PHP program using the following code.  The 
resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive 
lacks a file name.  So when a program like Google Earth tries to process 
the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file 
has no name but can otherwise be extracted just fine.  Once extracted, 
Google Earth can process the file.  Does anyone know how I might add the 
file name information to the ndfdViaPipe.kmz?  The reason I'm trying 
to use pipes is to avoid creating a file with the dynamically created 
data in $kml_string.  The plan is to send $kmz_content out in a SOAP 
service message with the payload as base64 encoded file.  If there is a 
better way to accomplish this I am certainly open to suggestions.


In advance, thanks for any help you care to offer.

John

?php

$kml_string = ?xml version=\1.0\ encoding=\UTF-8\?;
$kml_string = $kml_string . kml 
xmlns=\http://earth.google.com/kml/2.1\;;

$kml_string = $kml_string . Document;
$kml_string = $kml_string .nameNational Digital Forecast Database 
Data/name;

$kml_string = $kml_string .open1/open;
$kml_string = $kml_string .   Schema parent=\Placemark\ 
name=\NdfdData\;
$kml_string = $kml_string . SimpleField type=\wstring\ 
name=\UOM\/SimpleField;
$kml_string = $kml_string . SimpleField type=\wstring\ 
name=\ValidTime\/SimpleField;
$kml_string = $kml_string . SimpleField type=\int\ 
name=\MaxTemp\/SimpleField;

$kml_string = $kml_string .   /Schema;
$kml_string = $kml_string .   NdfdData;
$kml_string = $kml_string . nameMaximum Temperature/name;
$kml_string = $kml_string . description90F valid at 
2007-06-26T00:00:00-04:00/description;

$kml_string = $kml_string . Point;
$kml_string = $kml_string .   coordinates-77.37,37.82/coordinates;
$kml_string = $kml_string . /Point;
$kml_string = $kml_string . UOMF/UOM;
$kml_string = $kml_string . 
ValidTime2007-06-26T00:00:00-04:00/ValidTime;

$kml_string = $kml_string . MaxTemp95/MaxTemp;
$kml_string = $kml_string .   /NdfdData;
$kml_string = $kml_string .   NdfdData;
$kml_string = $kml_string . nameMaximum Temperature/name;
$kml_string = $kml_string . description89F valid at 
2007-06-26T00:00:00-04:00/description;

$kml_string = $kml_string . Point;
$kml_string = $kml_string .   coordinates-77.5,38.00/coordinates;
$kml_string = $kml_string . /Point;
$kml_string = $kml_string . UOMF/UOM;
$kml_string = $kml_string . 
ValidTime2007-06-26T00:00:00-04:00/ValidTime;

$kml_string = $kml_string . MaxTemp89/MaxTemp;
$kml_string = $kml_string .   /NdfdData;
$kml_string = $kml_string . /Document;
$kml_string = $kml_string . /kml;

$descriptorAssignments = array(
  0 = array(pipe, r),  // stdin is a pipe that the child will read 
from
  1 = array(pipe, w),  // stdout is a pipe that the child will 
write to
  2 = array(file, /tmp/error-output.txt, a) // stderr is a file 
to write to

);

$kmz_process = proc_open('zip',$descriptorAssignments,$pipes);

if (is_resource($kmz_process))
{
  fwrite($pipes[0],$kml_string);
  fclose($pipes[0]);

  $kmz_content = stream_get_contents($pipes[1]);

  fclose($pipes[1]);

  $return_value = proc_close($kmz_process);

  //  Only outputting data to ensure it is a properly formatted zip file
  //  Normally, a SOAP service will sent the data as a base64 encoded 
payload

  $output_file = fopen('ndfdViaPipe.kmz','w');
  fwrite($output_file,$kmz_content);
  fclose($output_file);
}

?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating a File in Memory

2007-09-07 Thread Graham Cossey
Can't help with your main problem, however I find it easier to write
the likes of :

$kml_string = $kml_string . Document;

as:

 $kml_string .= Document;

;-)

On 9/7/07, John Schattel [EMAIL PROTECTED] wrote:
 Hello All,

 I am trying to zip data in a PHP program using the following code.  The
 resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive
 lacks a file name.  So when a program like Google Earth tries to process
 the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file
 has no name but can otherwise be extracted just fine.  Once extracted,
 Google Earth can process the file.  Does anyone know how I might add the
 file name information to the ndfdViaPipe.kmz?  The reason I'm trying
 to use pipes is to avoid creating a file with the dynamically created
 data in $kml_string.  The plan is to send $kmz_content out in a SOAP
 service message with the payload as base64 encoded file.  If there is a
 better way to accomplish this I am certainly open to suggestions.

 In advance, thanks for any help you care to offer.

 John

 ?php

 $kml_string = ?xml version=\1.0\ encoding=\UTF-8\?;
 $kml_string = $kml_string . kml
 xmlns=\http://earth.google.com/kml/2.1\;;
 $kml_string = $kml_string . Document;
 $kml_string = $kml_string .nameNational Digital Forecast Database
 Data/name;
 $kml_string = $kml_string .open1/open;
 $kml_string = $kml_string .   Schema parent=\Placemark\
 name=\NdfdData\;
 $kml_string = $kml_string . SimpleField type=\wstring\
 name=\UOM\/SimpleField;
 $kml_string = $kml_string . SimpleField type=\wstring\
 name=\ValidTime\/SimpleField;
 $kml_string = $kml_string . SimpleField type=\int\
 name=\MaxTemp\/SimpleField;
 $kml_string = $kml_string .   /Schema;
 $kml_string = $kml_string .   NdfdData;
 $kml_string = $kml_string . nameMaximum Temperature/name;
 $kml_string = $kml_string . description90F valid at
 2007-06-26T00:00:00-04:00/description;
 $kml_string = $kml_string . Point;
 $kml_string = $kml_string .   coordinates-77.37,37.82/coordinates;
 $kml_string = $kml_string . /Point;
 $kml_string = $kml_string . UOMF/UOM;
 $kml_string = $kml_string . 
 ValidTime2007-06-26T00:00:00-04:00/ValidTime;
 $kml_string = $kml_string . MaxTemp95/MaxTemp;
 $kml_string = $kml_string .   /NdfdData;
 $kml_string = $kml_string .   NdfdData;
 $kml_string = $kml_string . nameMaximum Temperature/name;
 $kml_string = $kml_string . description89F valid at
 2007-06-26T00:00:00-04:00/description;
 $kml_string = $kml_string . Point;
 $kml_string = $kml_string .   coordinates-77.5,38.00/coordinates;
 $kml_string = $kml_string . /Point;
 $kml_string = $kml_string . UOMF/UOM;
 $kml_string = $kml_string . 
 ValidTime2007-06-26T00:00:00-04:00/ValidTime;
 $kml_string = $kml_string . MaxTemp89/MaxTemp;
 $kml_string = $kml_string .   /NdfdData;
 $kml_string = $kml_string . /Document;
 $kml_string = $kml_string . /kml;

 $descriptorAssignments = array(
0 = array(pipe, r),  // stdin is a pipe that the child will read
 from
1 = array(pipe, w),  // stdout is a pipe that the child will
 write to
2 = array(file, /tmp/error-output.txt, a) // stderr is a file
 to write to
 );

 $kmz_process = proc_open('zip',$descriptorAssignments,$pipes);

 if (is_resource($kmz_process))
 {
fwrite($pipes[0],$kml_string);
fclose($pipes[0]);

$kmz_content = stream_get_contents($pipes[1]);

fclose($pipes[1]);

$return_value = proc_close($kmz_process);

//  Only outputting data to ensure it is a properly formatted zip file
//  Normally, a SOAP service will sent the data as a base64 encoded
 payload
$output_file = fopen('ndfdViaPipe.kmz','w');
fwrite($output_file,$kmz_content);
fclose($output_file);
 }

 ?

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Graham

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating a File in Memory

2007-09-07 Thread Michael Preslar
Can't help with your main problem, however I find it easier to write
the likes of :

$kml_string = STOP
all of
the soap
maybe some water
some chips if you have them
STOP

On 9/7/07, John Schattel [EMAIL PROTECTED] wrote:
 Hello All,

 I am trying to zip data in a PHP program using the following code.  The
 resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive
 lacks a file name.  So when a program like Google Earth tries to process
 the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file
 has no name but can otherwise be extracted just fine.  Once extracted,
 Google Earth can process the file.  Does anyone know how I might add the
 file name information to the ndfdViaPipe.kmz?  The reason I'm trying
 to use pipes is to avoid creating a file with the dynamically created
 data in $kml_string.  The plan is to send $kmz_content out in a SOAP
 service message with the payload as base64 encoded file.  If there is a
 better way to accomplish this I am certainly open to suggestions.

 In advance, thanks for any help you care to offer.

 John

 ?php

 $kml_string = ?xml version=\1.0\ encoding=\UTF-8\?;
 $kml_string = $kml_string . kml
 xmlns=\http://earth.google.com/kml/2.1\;;
 $kml_string = $kml_string . Document;
 $kml_string = $kml_string .nameNational Digital Forecast Database
 Data/name;
 $kml_string = $kml_string .open1/open;
 $kml_string = $kml_string .   Schema parent=\Placemark\
 name=\NdfdData\;
 $kml_string = $kml_string . SimpleField type=\wstring\
 name=\UOM\/SimpleField;
 $kml_string = $kml_string . SimpleField type=\wstring\
 name=\ValidTime\/SimpleField;
 $kml_string = $kml_string . SimpleField type=\int\
 name=\MaxTemp\/SimpleField;
 $kml_string = $kml_string .   /Schema;
 $kml_string = $kml_string .   NdfdData;
 $kml_string = $kml_string . nameMaximum Temperature/name;
 $kml_string = $kml_string . description90F valid at
 2007-06-26T00:00:00-04:00/description;
 $kml_string = $kml_string . Point;
 $kml_string = $kml_string .   coordinates-77.37,37.82/coordinates;
 $kml_string = $kml_string . /Point;
 $kml_string = $kml_string . UOMF/UOM;
 $kml_string = $kml_string . 
 ValidTime2007-06-26T00:00:00-04:00/ValidTime;
 $kml_string = $kml_string . MaxTemp95/MaxTemp;
 $kml_string = $kml_string .   /NdfdData;
 $kml_string = $kml_string .   NdfdData;
 $kml_string = $kml_string . nameMaximum Temperature/name;
 $kml_string = $kml_string . description89F valid at
 2007-06-26T00:00:00-04:00/description;
 $kml_string = $kml_string . Point;
 $kml_string = $kml_string .   coordinates-77.5,38.00/coordinates;
 $kml_string = $kml_string . /Point;
 $kml_string = $kml_string . UOMF/UOM;
 $kml_string = $kml_string . 
 ValidTime2007-06-26T00:00:00-04:00/ValidTime;
 $kml_string = $kml_string . MaxTemp89/MaxTemp;
 $kml_string = $kml_string .   /NdfdData;
 $kml_string = $kml_string . /Document;
 $kml_string = $kml_string . /kml;

 $descriptorAssignments = array(
0 = array(pipe, r),  // stdin is a pipe that the child will read
 from
1 = array(pipe, w),  // stdout is a pipe that the child will
 write to
2 = array(file, /tmp/error-output.txt, a) // stderr is a file
 to write to
 );

 $kmz_process = proc_open('zip',$descriptorAssignments,$pipes);

 if (is_resource($kmz_process))
 {
fwrite($pipes[0],$kml_string);
fclose($pipes[0]);

$kmz_content = stream_get_contents($pipes[1]);

fclose($pipes[1]);

$return_value = proc_close($kmz_process);

//  Only outputting data to ensure it is a properly formatted zip file
//  Normally, a SOAP service will sent the data as a base64 encoded
 payload
$output_file = fopen('ndfdViaPipe.kmz','w');
fwrite($output_file,$kmz_content);
fclose($output_file);
 }

 ?

 --
 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