RE: Re: How do I specify a local file for fopen()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would like to change my answer to that question. Due to my lack in desire, to read the entire email at first
I have made a bad judgment error in exactly what you was trying to do.

Yes trying to open a file on your local computer from the server is not a good idea. 
HOW EVER.
There are many options.
A FTP option
$handle = fopen("ftp://user:password@xxxxxxxxxxxxx/somefile.txt";, "w");
Providing you have the ftp port open into your network/computer for ftp access.

Personally I would never do that.


-----Original Message-----
From: news [mailto:news@xxxxxxxxxxxxx] On Behalf Of Colin Guthrie
Sent: Monday, November 05, 2007 4:06 AM
To: php-general@xxxxxxxxxxxxx
Subject:  Re: How do I specify a local file for fopen()?

Jon Westcot wrote:
> Hi all:
> 
> I've been beating my head against a brick wall trying to figure this
> out and I'm still no closer than I was two weeks ago.
> 
> How do I specify a local file on my computer to use with fopen() on
> the server?

Keep on beating it until you get the concept of client-server computing :p

There is no standard way a webserver can access information on the
client's computer. Enabling this kind of interaction would be a complete
no-no from a security perspective and it would also require that a
channel be opened *from* the server *to* the client (which is the
opposite way round - e.g. the client becomes a server and the server
becomes a client!

> I've checked and the allow_url_fopen setting is set to On.  I use the
> html <input type="file"> to let me browse to the file.  This,
> however, forces me to also POST the entire file to the server, which
> I DO NOT WANT it to do.  I just wanted to be able to use the <Browse>
> button to get to the file name.  But, even when I do this, the file
> name returned in the $_FILES array doesn't give me a file name that
> fopen() will actually open.

This is how you send files to the webserver. If you want the server to
access the files on the client then you have to either send them or
provide some way for the client to become a server in some capacity
through the running of a local application (or Java Applet), and then
you have to make sure you can negotiate any firewall and NAT'ed gateways
that may be inbetween!


> Do I somehow have to get the server to recognize my computer as an
> http-based address?  If so, how do I do this?  The computer that has
> the file to be opened is a Windows-based computer (running WinXP or
> Vista), and it obviously has an Internet connection.  Do I need to
> retrieve, from the server, my computer's IP address and use that, in
> whole or in part, to reference the file to be opened?  If so, how?

It's one of the ways, or you could just setup the client to do a samba
share and mount it on the server, or any number of other techniques.
Obviously this architecture only has legs in a very locked down and
standard environment - it's no good for the open internet.

> While I'm asking questions, does anyone know how to keep the file
> referenced in the <input type="file"> setup from actually being sent?
> All I think I really need is the NAME of the file, not its actual
> contents, since I'm hoping to use fopen() to open the file and then
> to use fgetcsv() to retrieve the contents.

The name gives you nothing, as there is no way to hook back to the
client! You're approach is fundamentally wrong.


> ANY help you all can send my way will be greatly appreciated!

Depending what you want your app to do you need to look at running
something locally on the client. One method that spring to mind would be
a Java applet that can run load up the local files and then manipulate
them accordingly, potentially speaking to webservices provided by your
server in the process.


Col

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux