SVG and PHP

SVG and PHP

am 05.01.2010 20:57:52 von Alice Wei

--_34491803-bef6-4480-93b5-ca581e156118_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable


Hi,

Just went online and saw an SVG generated from Python=2C and wanted to do=
the similar thing by loading the SVG into an PHP script. Here is the scrip=
t that I have:=20

=20
#Load the Map
$ourFileName=3D "USA_Counties_with_FIPS_and_names.svg"=3B
$fh =3D fopen($ourFileName=2C "r") or die("Can't open file")=3B
fclose($fh);

?>

The problem is that my screen appears as blank even though I could open up =
USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone=
know what I might have done wrong here?=20

Thanks in advance.=20

Alice
=20
____________________________________________________________ _____
Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/=

--_34491803-bef6-4480-93b5-ca581e156118_--

Re: SVG and PHP

am 05.01.2010 21:02:15 von Ashley Sheridan

--=-7mU8AnovJIDHNqCgWSjU
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, 2010-01-05 at 14:57 -0500, Alice Wei wrote:

> Hi,=20
>=20
> Just went online and saw an SVG generated from Python, and wanted to do=
the similar thing by loading the SVG into an PHP script. Here is the scrip=
t that I have:=20
>=20
> > =20
> #Load the Map
> $ourFileName=3D "USA_Counties_with_FIPS_and_names.svg";
> $fh =3D fopen($ourFileName, "r") or die("Can't open file");
> fclose($fh);=20
>=20
> ?>
>=20
> The problem is that my screen appears as blank even though I could open u=
p USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyo=
ne know what I might have done wrong here?=20
>=20
> Thanks in advance.=20
>=20
> Alice
> =20
> ____________________________________________________________ _____
> Hotmail: Trusted email with Microsoftâ€=99s powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/177141664/direct/01/


If you go the fopen route, you need to get the contents of the file and
print them out to the browser, with the correct SVG headers. All you're
doing here creating a read-only resource to the file.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-7mU8AnovJIDHNqCgWSjU--

Re: SVG and PHP

am 05.01.2010 21:02:37 von Bruno Fajardo

--001636c9274ce26b7b047c705124
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

2010/1/5 Alice Wei

>
> Hi,
>
> Just went online and saw an SVG generated from Python, and wanted to do
> the similar thing by loading the SVG into an PHP script. Here is the scri=
pt
> that I have:
>
> >
> #Load the Map
> $ourFileName=3D "USA_Counties_with_FIPS_and_names.svg";
> $fh =3D fopen($ourFileName, "r") or die("Can't open file");
> fclose($fh);
>
> ?>
>
> The problem is that my screen appears as blank even though I could open u=
p
> USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyo=
ne
> know what I might have done wrong here?
>

Aren't you just opening the file? I think that you need to print it in some
way suitable to your application.
Try using fread() or other function to read the contents of the file.


>
> Thanks in advance.
>
> Alice
>
> ____________________________________________________________ _____
> Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/177141664/direct/01/

--001636c9274ce26b7b047c705124--

RE: SVG and PHP

am 05.01.2010 21:15:12 von Alice Wei

--_b2a8ebd8-9210-4d21-8435-7dc3ef425231_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable




Hi=2C



Just went online and saw an SVG generated from Python=2C and wanted to do=
the similar thing by loading the SVG into an PHP script. Here is the scrip=
t that I have:






#Load the Map

$ourFileName=3D "USA_Counties_with_FIPS_and_names.svg"=3B

$fh =3D fopen($ourFileName=2C "r") or die("Can't open file")=3B

fclose($fh)=3B



?>



The problem is that my screen appears as blank even though I could open up =
USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone=
know what I might have done wrong here?

Aren't you just opening the file? I think that you need to print it in some=
way suitable to your application.


Try using fread() or other function to read the contents of the file.
=20
Well=2C I tried=2C and here is the complete code of the portion I just ed=
ited:

#Load the Map
$ourFileName=3D "USA_Counties_with_FIPS_and_names.svg"=3B
$fh =3D fopen($ourFileName=2C "r") or die("Can't open file")=3B
$contents =3D fread($fh=2Cfilesize($ourFileName))=3B
echo $contents=3B
fclose($fh);
=20
Now I get something on the screen=2C but still no image: image/svg+xml
Um=2C is there anything particular I need to put in my code?=20


Thanks in advance.



Alice



____________________________________________________________ _____

Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.

http://clk.atdmt.com/GBL/go/177141664/direct/01/ =20
____________________________________________________________ _____
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/=

--_b2a8ebd8-9210-4d21-8435-7dc3ef425231_--

RE: SVG and PHP

am 05.01.2010 21:20:26 von Ashley Sheridan

--=-UabJPMOSCGM1yNR2VnnZ
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, 2010-01-05 at 15:15 -0500, Alice Wei wrote:

>=20
>=20
> Hi,
>=20
>=20
>=20
> Just went online and saw an SVG generated from Python, and wanted to do=
the similar thing by loading the SVG into an PHP script. Here is the scrip=
t that I have:
>=20
>=20
>=20
> >=20
>=20
>=20
> #Load the Map
>=20
> $ourFileName=3D "USA_Counties_with_FIPS_and_names.svg";
>=20
> $fh =3D fopen($ourFileName, "r") or die("Can't open file");
>=20
> fclose($fh);
>=20
>=20
>=20
> ?>
>=20
>=20
>=20
> The problem is that my screen appears as blank even though I could open u=
p USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyo=
ne know what I might have done wrong here?
>=20
> Aren't you just opening the file? I think that you need to print it in so=
me way suitable to your application.
>=20
>=20
> Try using fread() or other function to read the contents of the file.
> =20
> Well, I tried, and here is the complete code of the portion I just edit=
ed:
>=20
> #Load the Map
> $ourFileName=3D "USA_Counties_with_FIPS_and_names.svg";
> $fh =3D fopen($ourFileName, "r") or die("Can't open file");
> $contents =3D fread($fh,filesize($ourFileName));
> echo $contents;
> fclose($fh);=20
> =20
> Now I get something on the screen, but still no image: image/svg+xml
> Um, is there anything particular I need to put in my code?=20
>=20
>=20
> Thanks in advance.
>=20
>=20
>=20
> Alice
>=20
>=20
>=20
> ____________________________________________________________ _____
>=20
> Hotmail: Trusted email with Microsoftâ€=99s powerful SPAM protection.
>=20
> http://clk.atdmt.com/GBL/go/177141664/direct/01/ =20
> ____________________________________________________________ _____
> Hotmail: Trusted email with powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/177141665/direct/01/


View the source of your browser. Is it showing the SVG code? You need to
output the correct mime-type headers for the SVG, as by default, PHP
outputs headers for HTML. Something like this should do the trick:

header("Content-type: image/svg+xml");

This has to occur before any output has already been sent to the
browser, otherwise you'll get a headers already sent error.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-UabJPMOSCGM1yNR2VnnZ--

RE: SVG and PHP

am 05.01.2010 22:07:11 von Alice Wei

--_f7c9f7de-0fbb-43b1-a3c2-7ce3a554a71a_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable








=20
=20


On Tue=2C 2010-01-05 at 15:15 -0500=2C Alice Wei wrote:



Hi=2C



Just went online and saw an SVG generated from Python=2C and wanted to do=
the similar thing by loading the SVG into an PHP script. Here is the scrip=
t that I have:






#Load the Map

$ourFileName=3D "USA_Counties_with_FIPS_and_names.svg"=3B

$fh =3D fopen($ourFileName=2C "r") or die("Can't open file")=3B

fclose($fh)=3B



?>



The problem is that my screen appears as blank even though I could open up =
USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone=
know what I might have done wrong here?

Aren't you just opening the file? I think that you need to print it in some=
way suitable to your application.


Try using fread() or other function to read the contents of the file.
=20
Well=2C I tried=2C and here is the complete code of the portion I just ed=
ited:

#Load the Map
$ourFileName=3D "USA_Counties_with_FIPS_and_names.svg"=3B
$fh =3D fopen($ourFileName=2C "r") or die("Can't open file")=3B
$contents =3D fread($fh=2Cfilesize($ourFileName))=3B
echo $contents=3B
fclose($fh);
=20
Now I get something on the screen=2C but still no image: image/svg+xml
Um=2C is there anything particular I need to put in my code?=20


Thanks in advance.



Alice



____________________________________________________________ _____

Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.

http://clk.atdmt.com/GBL/go/177141664/direct/01/ =20
____________________________________________________________ _____
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/




View the source of your browser. Is it showing the SVG code? You need to ou=
tput the correct mime-type headers for the SVG=2C as by default=2C PHP outp=
uts headers for HTML. Something like this should do the trick:



header("Content-type: image/svg+xml")=3B



This has to occur before any output has already been sent to the browser=2C=
otherwise you'll get a headers already sent error.


Thanks=2C this time it does the trick.=20





Thanks=2C

Ash

http://www.ashleysheridan.co.uk







=20
____________________________________________________________ _____
Hotmail: Free=2C trusted and rich email service.
http://clk.atdmt.com/GBL/go/171222984/direct/01/=

--_f7c9f7de-0fbb-43b1-a3c2-7ce3a554a71a_--