开发者

Upload a file using Java Swing coupled with php in the server side

开发者 https://www.devze.com 2023-04-04 14:59 出处:网络
I have a Java Swing application that needs to upload a file to the server. My server is a an Apache. I know that I can do this with a Servlet but I don\'t want to install/maintain a Tomcat server. So

I have a Java Swing application that needs to upload a file to the server. My server is a an Apache. I know that I can do this with a Servlet but I don't want to install/maintain a Tomcat server. So I'am wondering is it possible to do it with a PHP script 开发者_如何学运维in the server side ?

Thanks


Well you can do that using jakarta HttpClient library

"Upload file HttpClient"

The article has both server side (php) and client side (java) code

you need to specify the folder on the PHP code, it is already doing through the method

move_uploaded_file ($_FILES['userfile'] ['tmp_name'], $_FILES['userfile'] ['name']); 

This function checks to ensure that the file designated by $_FILES['userfile'] ['tmp_name'] is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by $_FILES['userfile'] ['name'].

0

精彩评论

暂无评论...
验证码 换一张
取 消