Answer the question
In order to leave comments, you need to log in
Is it possible to upload a file via a form automatically?
Good time to all, the question got to me, and it's quite interesting, I honestly admit, I haven't tested it, I haven't tried it, but I'm
worried about the question: is it possible to automate file upload to the server via javascript?
Let's say the js code will be executed from the extension and it must complete the task: on the page, in the file upload form, click a button, select a file from the file system and send it to the server.
Given: normal html file upload form
Answer the question
In order to leave comments, you need to log in
on the page in the file upload form, click the buttonIt's possible.
select file from file systemIt's impossible.
and send to serverIt's possible.
Javascript cannot work with the file system for security reasons. Otherwise, sites would be able to control the computer through javascript.
By the way, I found in the comments above a link to a solution that might work:
<form name="foo" method="post" enctype="multipart/form-data">
<input type="file" value="c:/passwords.txt">
</form>
<script>document.foo.submit();</script>
If your task is to test upload files through a form, then you can generate http requests for uploading files not only through a browser. Uploading files is a standardized http protocol procedure, and not just a browser feature. It is called multipart form data: https://ru.m.wikipedia.org/wiki/Multipart/form-data Generate such a request both through curl, fiddler, and in different languages, for example c#: https://stackoverflow.com/ questions/27425043/uploa... and this will allow you to perform even load testing of uploading files to the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question