I require to upload a file using a PHP page into a Java Servlet. The Java Servlet uses the HTTP Post for uploading the files. Is there a way to do this. Could you please advice on how this is done. I am pretty new to uploading files in PHP and would like to understand the concept and also how my above functionality can be achieved. I right now dont have any code that I can look at putting here for someone to help me as I am starting a fresh on PHP file uploads. Also can i acheive this by using jquery.post?
Share
PHP is not relevant. It’s all about its generated HTML output. Just make sure that the PHP-generated form look like this (open page in browser, rightclick and View Source to verify it):
For the servlet end, just check How to upload files to server using JSP/Servlet?
If you really intend to use JavaScript to send the POST request asynchronously, checkout the jQuery Form plugin which simulates asynchronous file uploads by an
<iframe>hack, or HTML5/XHR2 which supports asynchronous file uploads natively.