ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Option one can handle HTTP uploads as well as FTP, but will probably require more learning (you have to do most things through curl's setopt function, and there's a hell of a lot in there to read through).
Option two is easier, but only does FTP transfers.
A third option is just to shell out from PHP and run the command line client of your choice... probably the easiest to make work, but the hardest to troubleshoot.
Sorry, I guess I wasn't clear - those functions execute on the server, because they're PHP functions. PHP never executes in the client's browser. If your script says
the situation is 2 linux servers. one is running PHP, another is running JSP servlet
how can i let the user click a link or button to trigger the action to upload a file from PHP server to JSP server directly?
PHP server will use the HTTP "put" the file to the JSP server. and the JSP server will receive it as a normal upload like HTTP <form action="servlet" method="" enctype="">
Yes, the curl functions (link #1) will do that. Read through the docs, especially the setopt function, because that's where the functionality really is.
The best way to start would be to get file uploads working (from the PHP server preferably, if you have command line access) with the command line curl tool - this will give you a head start on figuring out which options you will need to set when you use the library functions. As soon as you can upload the file and have the JSP servlet receive it correctly, the rest is just grunt work.
Warning: fopen("example_homepage.txt", "w") - Permission denied in /var/www/html/testcurl.php on line 4
Curl (the PHP library part) is definitely installed - you can tell because curl_setopt returned a warning message rather than an "unknown function" error. The first error is the source of the problem - your PHP script is probably running as a user that doesn't have permission to read the file you want to upload. Do you have shell access to this server?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.