Skip to content
Advertisement

Jmeter – Sending forms with file through JavaScript

I have a problem with sending form with file through JavaScript using Jmeter. It simply does not succeeded. Unfortunately I do not have any logs from that situation.

But when I am sending form without file parameter through JavaScript using Jmeter it succeeded. Once I add parameter with a file it does not.

Tried to check option in Jmeter Use multipart/form-data for POST with file upload section filled but it does not help.

In test I am using HTTP Request sampler with:

  • POST method
  • multipart/form-data for POST box is checked
  • In Files Upload section the following values are provided:
    File Path
    Parameter Name
    File MIME Type
  • additional parameters are provided for form

==== EDIT ====

Before – not working

BEFORE - NOT WORKING

After changes – working

AFTER - WORKING

Advertisement

Answer

Just record it

  1. Start JMeter’s HTTP(S) Test Script Recorder
  2. If your application uses HTTPS protocol – import JMeter’s self-signed certificate into your browser
  3. Configure your browser to use JMeter as the proxy
  4. Copy the file you’re going to upload to “bin” folder of your JMeter installation
  5. Perform the upload in browser
  6. JMeter will generate proper HTTP Request sampler and HTTP Header Manager
  7. Replay the request
  8. It should be successful (assuming the previous requests were, for example if you need to log in prior to uploading the file)

More information:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement