0

I'm looking for a way to add a string as a file inside a html form using JavaScript.

Now I know about the security issues the browsers have when it comes to files, but I'm not looking for adding a file path (as happens when you click the browse of a file input)!!
I want to add a string as a file (The server I'm hitting expects the post to include a file and not a simple form entry).

I know how to perform the action using the FormData object, but I don't want to generate a xhr(ajax) post. I need the post to be a simple form post since the server responds with a redirection.

Does anyone have an idea about this?

9
  • PHP would be able to create a fake file for you and do the post call through CURL. Commented Jan 30, 2017 at 13:26
  • What file type does it expect? Commented Jan 30, 2017 at 13:27
  • I need to do this using html + javascript. The file type is a simple text file. The content is a base64 string. Commented Jan 30, 2017 at 13:27
  • So did you search and file questions like this: stackoverflow.com/questions/31048215/… Does it help? Commented Jan 30, 2017 at 13:32
  • I did search SO and didn't find a suitable result. Commented Jan 30, 2017 at 13:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.