7

Is it possible to have a HTML form on server A and have it upload content to server B?

Can this be achieved? I am trying to use an iframe with the form starting on the other server, but I need information passed to the form from server A. Would I have to use javascript?

Thank you for your help!

tundoopani
  • 255
  • 9
  • 21

2 Answers2

6

As long as you're sending it via POST and your remote server is accepting that POST response, sure. No need for javascript, just set the form action to the remote server.

AlienWebguy
  • 76,997
  • 17
  • 122
  • 145
  • How can this be achieved? I have to solve the same problem, but I don't know how to POST the file name (or file field) and don't know what to do in the remote server when receiving the POST fields. – villamejia Dec 10 '16 at 16:10
  • You just include a `` field, and then make sure you add `enctype="multipart/form-data"` to your `
    ` tag so it knows how to encode it. On the server side just look in the FILES block of the request object. In PHP you have `$_POST` and you also have `$_FILES` so `$_FILES['myfile']` should give you the data you need. In Node/Express add the `connect-multiparty` middleware and you should find it in `req.files`
    – AlienWebguy Dec 11 '16 at 17:33
3

You can but the server b has to accept the upload. It has to be done on the server side. Using php or equivalent.

Here is a great tutorial

http://www.tizag.com/phpT/fileupload.php

JimmyB
  • 101
  • 6