open/download file not under www-root

Hi!

Windows 2003 Server/PHP 5.0.1

Is it possible to download a file from a server that is at for example u:/d=
ocuments/ which is not under the www-root?
How would I reference that file. (I just want to open it -for example a wor=
d-file)

/Gustav



No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 2007-09-03 =
09:31


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gustav Wiberg [ Di, 04 September 2007 12:21 ] [ ID #1812387 ]

RE: open/download file not under www-root

Gustav,


> Windows 2003 Server/PHP 5.0.1
>
> Is it possible to download a file from a server that is at for
> example u:/documents/ which is not under the www-root?
> How would I reference that file. (I just want to open it -for
> example a word-file)

Yes, you can. I actually let my [registered] users download files that are
stored on a different PC to the server. The server pulls the file across and
provides a header allowing download - mine are all PDFs but I don't see that
Word files would be a problem - just a different content-type.

I use Apache, but previously used IIS (NT4) without any problem. (I switched
to Apache to do some extra java stuff that was impossible under IIS.)

My code:

<?php
$fp=$_POST['fp'];
$tr_id=$_POST['tr_id'];
$fpd = "G:\\".$fp.".pdf";
$len = filesize($fpd);
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=$fpd");
header("Content-Title: $fpd");
header("Content-Length: $len");
readfile($fpd);
?>

Cheers

George

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
George.Pitcher [ Di, 04 September 2007 13:04 ] [ ID #1812388 ]

Re: open/download file not under www-root

----------MB_8C9BD00A6A126E0_40C_10A3D_webmail-mf15.sysops.a ol.com
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"


I thought accessing files/directories above the www-root via the web was impossible???

Tryst







-----Original Message-----
From: George Pitcher <george.pitcher [at] ingenta.com>
To: Gustav Wiberg <gustav [at] hmn.se>; php-windows [at] lists.php.net
Sent: Tue, 4 Sep 2007 12.04pm
Subject: RE: [PHP-WIN] open/download file not under www-root










Gustav,


> Windows 2003 Server/PHP 5.0.1
>
> Is it possible to download a file from a server that is at for
> example u:/documents/ which is not under the www-root?
> How would I reference that file. (I just want to open it -for
> example a word-file)

Yes, you can. I actually let my [registered] users download files that are
stored on a different PC to the server. The server pulls the file across and
provides a header allowing download - mine are all PDFs but I don't see that
Word files would be a problem - just a different content-type.

I use Apache, but previously used IIS (NT4) without any problem. (I switched
to Apache to do some extra java stuff that was impossible under IIS.)

My code:

<?php
$fp=$_POST['fp'];
$tr_id=$_POST['tr_id'];
$fpd = "G:\\".$fp.".pdf";
$len = filesize($fpd);
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=$fpd");
header("Content-Title: $fpd");
header("Content-Length: $len");
readfile($fpd);
?>

Cheers

George

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







____________________________________________________________ ____________
Get a FREE AOL Email account with unlimited storage. Plus, share and store photos and experience exclusively recorded live music Sessions from your favourite artists. Find out more at http://info.aol.co.uk/joinnow/?ncid=548.

----------MB_8C9BD00A6A126E0_40C_10A3D_webmail-mf15.sysops.a ol.com--
Trystano [ Di, 04 September 2007 13:48 ] [ ID #1812389 ]

Re: open/download file not under www-root

trystano [at] aol.com wrote:
> I thought accessing files/directories above the www-root via the web was impossible???

Directly yes, but you can proxy it through a server-side script.

-Stut

--
http://stut.net/

> -----Original Message-----
> From: George Pitcher <george.pitcher [at] ingenta.com>
> To: Gustav Wiberg <gustav [at] hmn.se>; php-windows [at] lists.php.net
> Sent: Tue, 4 Sep 2007 12.04pm
> Subject: RE: [PHP-WIN] open/download file not under www-root
>
> Gustav,
>
>
>> Windows 2003 Server/PHP 5.0.1
>>
>> Is it possible to download a file from a server that is at for
>> example u:/documents/ which is not under the www-root?
>> How would I reference that file. (I just want to open it -for
>> example a word-file)
>
> Yes, you can. I actually let my [registered] users download files that are
> stored on a different PC to the server. The server pulls the file across and
> provides a header allowing download - mine are all PDFs but I don't see that
> Word files would be a problem - just a different content-type.
>
> I use Apache, but previously used IIS (NT4) without any problem. (I switched
> to Apache to do some extra java stuff that was impossible under IIS.)
>
> My code:
>
> <?php
> $fp=$_POST['fp'];
> $tr_id=$_POST['tr_id'];
> $fpd = "G:\\".$fp.".pdf";
> $len = filesize($fpd);
> header("Content-Type: application/pdf");
> header("Content-Disposition: inline; filename=$fpd");
> header("Content-Title: $fpd");
> header("Content-Length: $len");
> readfile($fpd);
> ?>
>
> Cheers
>
> George

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stut [ Di, 04 September 2007 14:01 ] [ ID #1812390 ]

RE: open/download file not under www-root

Hi Stut!

Exactly what does that mean? Do you have any references? Please send :-)

Best regards
/Gustav Wiberg


-----Original Message-----
From: Stut [mailto:stuttle [at] gmail.com]
Sent: Tuesday, September 04, 2007 2:02 PM
To: trystano [at] aol.com
Cc: george.pitcher [at] ingenta.com; gustav [at] hmn.se; php-windows [at] lists.php.net
Subject: Re: [PHP-WIN] open/download file not under www-root

trystano [at] aol.com wrote:
> I thought accessing files/directories above the www-root via the web was=
impossible???

Directly yes, but you can proxy it through a server-side script.

-Stut

--
http://stut.net/

> -----Original Message-----
> From: George Pitcher <george.pitcher [at] ingenta.com>
> To: Gustav Wiberg <gustav [at] hmn.se>; php-windows [at] lists.php.net
> Sent: Tue, 4 Sep 2007 12.04pm
> Subject: RE: [PHP-WIN] open/download file not under www-root
>
> Gustav,
>
>
>> Windows 2003 Server/PHP 5.0.1
>>
>> Is it possible to download a file from a server that is at for
>> example u:/documents/ which is not under the www-root?
>> How would I reference that file. (I just want to open it -for
>> example a word-file)
>
> Yes, you can. I actually let my [registered] users download files that ar=
e
> stored on a different PC to the server. The server pulls the file across =
and
> provides a header allowing download - mine are all PDFs but I don't see t=
hat
> Word files would be a problem - just a different content-type.
>
> I use Apache, but previously used IIS (NT4) without any problem. (I switc=
hed
> to Apache to do some extra java stuff that was impossible under IIS.)
>
> My code:
>
> <?php
> $fp=3D$_POST['fp'];
> $tr_id=3D$_POST['tr_id'];
> $fpd =3D "G:\\".$fp.".pdf";
> $len =3D filesize($fpd);
> header("Content-Type: application/pdf");
> header("Content-Disposition: inline; filename=3D$fpd");
> header("Content-Title: $fpd");
> header("Content-Length: $len");
> readfile($fpd);
> ?>
>
> Cheers
>
> George

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


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 2007-09-03 =
09:31


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gustav Wiberg [ Di, 04 September 2007 15:02 ] [ ID #1812391 ]

Re: open/download file not under www-root

As long as the user that Apache is running under has NTFS read
permissions to the target folder, then you should have no problems. A
quick and dirty force method that I use would be something like this:

$file = "x:\\path\\to\\the\\file.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);

Note the double backslashes! Cheers.

Armando

Gustav Wiberg wrote:
> Hi Stut!
>
> Exactly what does that mean? Do you have any references? Please send :-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Stut [mailto:stuttle [at] gmail.com]
> Sent: Tuesday, September 04, 2007 2:02 PM
> To: trystano [at] aol.com
> Cc: george.pitcher [at] ingenta.com; gustav [at] hmn.se; php-windows [at] lists.php.net
> Subject: Re: [PHP-WIN] open/download file not under www-root
>
> trystano [at] aol.com wrote:
>> I thought accessing files/directories above the www-root via the web was impossible???
>
> Directly yes, but you can proxy it through a server-side script.
>
> -Stut
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Dijital [ Mi, 05 September 2007 04:09 ] [ ID #1813243 ]

RE: open/download file not under www-root

Hi!

Ok, I will try this... :-)

Best regards
/Gustav Wiberg


-----Original Message-----
From: Armando [mailto:dijital [at] shaw.ca]
Sent: Wednesday, September 05, 2007 4:10 AM
To: Gustav Wiberg
Cc: 'Stut'; 'trystano [at] aol.com'; 'george.pitcher [at] ingenta.com'; 'php-windows [at] =
lists.php.net'
Subject: Re: [PHP-WIN] open/download file not under www-root

As long as the user that Apache is running under has NTFS read
permissions to the target folder, then you should have no problems. A
quick and dirty force method that I use would be something like this:

$file =3D "x:\\path\\to\\the\\file.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=3D' . basename($file));
readfile($file);

Note the double backslashes! Cheers.

Armando

Gustav Wiberg wrote:
> Hi Stut!
>
> Exactly what does that mean? Do you have any references? Please send :-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Stut [mailto:stuttle [at] gmail.com]
> Sent: Tuesday, September 04, 2007 2:02 PM
> To: trystano [at] aol.com
> Cc: george.pitcher [at] ingenta.com; gustav [at] hmn.se; php-windows [at] lists.php.net
> Subject: Re: [PHP-WIN] open/download file not under www-root
>
> trystano [at] aol.com wrote:
>> I thought accessing files/directories above the www-root via the web wa=
s impossible???
>
> Directly yes, but you can proxy it through a server-side script.
>
> -Stut
>

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


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.485 / Virus Database: 269.13.5/990 - Release Date: 2007-09-04 =
22:36


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gustav Wiberg [ Mi, 05 September 2007 12:19 ] [ ID #1813244 ]

RE: open/download file not under www-root

Hi there!

Thank you! It worked so fine.. Cool! :-)

Best regards
/Gustav Wiberg


-----Original Message-----
From: Armando [mailto:dijital [at] shaw.ca]
Sent: Wednesday, September 05, 2007 4:10 AM
To: Gustav Wiberg
Cc: 'Stut'; 'trystano [at] aol.com'; 'george.pitcher [at] ingenta.com'; 'php-windows [at] =
lists.php.net'
Subject: Re: [PHP-WIN] open/download file not under www-root

As long as the user that Apache is running under has NTFS read
permissions to the target folder, then you should have no problems. A
quick and dirty force method that I use would be something like this:

$file =3D "x:\\path\\to\\the\\file.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=3D' . basename($file));
readfile($file);

Note the double backslashes! Cheers.

Armando

Gustav Wiberg wrote:
> Hi Stut!
>
> Exactly what does that mean? Do you have any references? Please send :-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Stut [mailto:stuttle [at] gmail.com]
> Sent: Tuesday, September 04, 2007 2:02 PM
> To: trystano [at] aol.com
> Cc: george.pitcher [at] ingenta.com; gustav [at] hmn.se; php-windows [at] lists.php.net
> Subject: Re: [PHP-WIN] open/download file not under www-root
>
> trystano [at] aol.com wrote:
>> I thought accessing files/directories above the www-root via the web wa=
s impossible???
>
> Directly yes, but you can proxy it through a server-side script.
>
> -Stut
>

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.485 / Virus Database: 269.13.5/990 - Release Date: 2007-09-04 =
22:36


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gustav Wiberg [ Mi, 05 September 2007 12:26 ] [ ID #1813245 ]
PHP » gmane.comp.php.windows » open/download file not under www-root

Vorheriges Thema: Browse/file-button - default path?
Nächstes Thema: Directory browser