Jump to content

File Transfer Method (CLI)


phporcaffeine

Recommended Posts

Interesting project here:

 

I'm using PHP (CLI) on a client machine, and I need a script on the client (executed via CLI) to transfer/upload a file to a web server using HTTPS (I could use HTTP if I have to).

 

The catch is, I can't use FTP methods (firewall/port issues) ... but I have complete control over the client machine as well as the server machine.  I can however use the following ports; 8080, 443 & 3306.

 

I realize that of the three ports I can use, 8080 would be the best but still not suited for mass data blocks.  I think 8080 will be okay because I am transferring files that are less than 5k.

 

Anywho, I thought I could get away with fopen() but I'm reading in the manual that the HTTP & HTTPS wrappers are 'read-only' which isn't going to work (because I am trying to write a file to the server, not read one).

 

So as I research further I am think that somehow 'sockets' might do the trick.  I have a very basic understanding of sockets & php but I would like to know if I could do what I am trying to do using sockets?

 

-TIA

Link to comment
Share on other sites

Ummm no offense, but that made no sense at all.

 

So you're trying to upload a file to a webserver using PHP?  Google PHP uploads... No fancy socket manipulation is necessary or anything.

 

If you mean you want to  upload a file, and then the server run it before saying something, then that's possible in the same way.

Link to comment
Share on other sites

Ummm no offense, but that made no sense at all.

 

So you're trying to upload a file to a webserver using PHP?  Google PHP uploads... No fancy socket manipulation is necessary or anything.

 

If you mean you want to  upload a file, and then the server run it before saying something, then that's possible in the same way.

 

Wouldn't I need a script on the server to accept the $FILES[] post from the CLI script?  See I'm trying to avoid user interaction.

 

I guess I could 'forge' a form submit with JavaScript but I don't know if echo'ed JS will work in CLI?

Link to comment
Share on other sites

Oooohhhh!!! I get what you're trying to do now.... You could do it via the cURL library maybe....

 

Okay, I'll google up on cURL

 

BTW:

 

Using PHP in CLI means I wouldn't have a browser, which means no HTML which means no FORM to POST with ... etc

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.