Forum Moderators: coopster

Message Too Old, No Replies

Writing a file on the server using fsockopen

write data using fsockopen()

         

crypto

10:02 am on Feb 3, 2003 (gmt 0)

10+ Year Member



Hi everyone,

I want to write a file on a remote server using fsockopen(). Is there a way to do it?

Any suggestions are welcome.

jatar_k

6:32 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



crypto,

Have you read through this?
[php.net...]

fsockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fputs(), fclose(), and feof()).

andreasfriedrich

7:45 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Of course you would need to use whatever protocol the process listening on the port you are connecting to expects.

crypto

7:36 am on Feb 4, 2003 (gmt 0)

10+ Year Member



yes jatar I have been thru the URL that u gave. Let
me reframe my question: "I've got the path of a
directory on a remote web-server. Now I want to store a
file in that directory using fsockopen. First of all is
it possible to do this without a program at the other end
listening to my program? Also can it be done over TCP
using which port?"

I know how to use HTTP POST and GET methods using fsockopen() but I am clueless on this one.

synkronus

2:29 pm on Feb 4, 2003 (gmt 0)

10+ Year Member



script an FTP client maybe (or find a tute)? unless the remote server has a specific protocol you were thinking of using?

andreasfriedrich

3:34 pm on Feb 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



crypto [webmasterworld.com] wrote at 07:36 on Feb. 04, 2003 in message #4 [webmasterworld.com]
First of all is
it possible to do this without a program at the other end
listening to my program? Also can it be done over TCP
using which port?

No. There has to be some process that listens for connections to the port you are using.

Unless you specify to use a unix socket in which case you could only connect to some local socket or explicitly specify the ud protocol fsockopen will use the tcp protocol to connect to the host. The port will depend on which service you want to use.

Why not use the ftp_* functions? Writing your own ftp client using fsockopen is not as trivial as talking HTTP to a webserver. Since most ftp servers will only accept passive ftp you would need to parse the string returned by the PASV [cr.yp.to] command and make a second connection using the ip and port number specified by the server.

Andreas

crypto

8:47 am on Feb 5, 2003 (gmt 0)

10+ Year Member



ya Andreas I guess I will have to work with ftp functions.
Anyways thanx for your ideas guys.