'Form POST from local file to website?
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.
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
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.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | Federico |
| Solution 3 | Robin Stewart |
