2

Pretty sure the answer is no, but I've not been able to articulate the question in a way that's let me find a definitive answer via search.

Can I make a local html file that submits a form to a website, and have that data accepted?

At work I basically copy info, from an xml source that arrives email by email, into multiple tools. This feels a bit like a job for a robot. I'd like to make a webpage that accepts the xml file and automatically sorts the data into form fields that I can submit via POST directly to the web tools.

  • Can't be done without a webserver right?
  • And even then, cross domain posting is usually disallowed?

I don't have access to the databases or apis unfortunately. And we use IE9, so I don't think there's an approach like greasemonkey or a homemade extension that I could leverage to move the data directly into the webform on page.

Thanks for confirming if this is possible or not.

ConcreteKiwi
  • 57
  • 1
  • 6
  • Thanks to everyone who replied. All good answers that helped me a lot! I can only pick one answer and don't have enough rep to vote everyone sorry/ – ConcreteKiwi Mar 26 '15 at 07:00

4 Answers4

0

Cross-domain posting is the source of Cross-Site Request Forgery vulnerabilities. Since JavaScript can submit forms, and your login is based on your browser, a site you visit can autopopulate a form and submit it in the background of a site you visit and it will be submitted on your behalf.

So it will work if there aren't protections in place to prevent that (generally a security token stored in the session and submitted as part of the form).

Elle H
  • 11,837
  • 7
  • 39
  • 42
0

You can parse the XML with JavaScript and then submit them to any server. You would have to copy the XML content into your webpage. If you want the website to load the XML file you have to use PHP.

For parsing XML look here

It's only forbidden to load data with AJAX (different server) due to the Cross-Domain-Policy. Of course you can post data to any server. And you can load data (XML) with PHP.

Community
  • 1
  • 1
maxeh
  • 1,373
  • 1
  • 15
  • 24
0

if I understand correctly the answer is

yes you can run any html file from your local computer.... just open the file with your browser.

yes you can submit a form to wherever you like....

To get data from XML to your html form... this can be realized in many ways with many different codes... JavaScript being one way.

You can access the xml content with ajax... get the necessary data into the form(s) .... submit form(s) to relatives targets.

Federico
  • 1,231
  • 9
  • 13
0

I tried this today using Chrome and Safari and found they do not pass any POST data if the html file with the form is on the local filesystem and the form's action points to a remote server.

<!-- When this form is hosted locally, POST variables are not sent -->
<form action="https://www.example.com/my_script" method="post">
    <input type="text" name="name">
</form>

(I verified the code by trying it with the html form on the remote server instead, in which case the POST worked as expected.)

Robin Stewart
  • 3,147
  • 20
  • 29