0

I have a wordpress site where I want users to be able to upload files to the api url of a separate server called Server2.

I have been able to get this to work in two separate ways, but each has it's drawbacks.

Option 1) Redirecting back to the page itself on the action of the form allows me to submit via curl on the post and upload the file to Server2, but first it uploads the files to the temp location on the webserver. The webserver is limited in the size of files it can transfer and it also involves sending the file twice.

Option 2) Set the action of the form to the receiving url on Server2. Works well with the file upload and we don't run into the size limitation, but on the completion of the upload, the page goes to the url of Server2 and displays the result message from the upload. I don't have access to Server2 to redirect back.

I would like to be able to post the file to Server2 without actually going to the page as we do with curl, without having to upload the file to the webserver first. Is this possible?

JGO0510
  • 211
  • 2
  • 3
  • 2
    you can use some javascript to build a hidden iframe with the file upload in there and try to submit it to the other server. never tried that myself, though. it MIGHT be subject to same-origin security restrictions. – Marc B Nov 18 '14 at 15:41
  • You can use AJAX/Javascript or use a target in your form that points to an iframe. If you don't have access to redirect then these are the two options. – Pradeep Nov 18 '14 at 16:53
  • @MarcB I was able to put an iframe in, which does allow for the file upload and is a better solution, but we're still left with the result message, just in the iframe, instead of the whole page. – JGO0510 Nov 18 '14 at 17:22
  • @Pradeep what does the AJAX/Javascript solution entail? – JGO0510 Nov 18 '14 at 17:23
  • @JGO0510: the iframe doesn't have to be visible. it just has to exist, really. – Marc B Nov 18 '14 at 17:49
  • Check this solution: http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload – Pradeep Nov 18 '14 at 19:48

0 Answers0