I have a form that posts a file to a site that I don’t have control and that site responds with a dynamically generated text file based on the uploaded file. That response is downloaded by the client after the form is submitted. My question is: how can I grab this text file and copy it to my server before it gets to the user?
Possible solution 1: is there a way to change this file’s headers and put its content to some hidden div or iframe?
Possible solution 2: I think the best way is that I create a script that gets the form data and then reposts it to the external site and then gets the response and writes this response to my site in a txt file. Unfortunately all my attempts to get this working have failed.
Example of solution 2:
<form action="mysite.com/respostScriptThatGrabsResponse.php" method="post">
<input type="file" name="filename"/>
<input type="submit" value="submit"/>
</from>
Theory #2 would be the way to go. You could use cURL to post the data to the external site. The most likely obstacle preventing success would be the external site requiring cookie data that only the client would have.