Jacob Sharir is the head of Professional Services and Support at BlazeMeter. With more than 3 years of experience in performance testing and customer facing positions while managing a global team, Jacob is an expert in the fields of load testing with open-source tools like JMeter, system engineering, AWS EC2 and CI tools like Jenkins and TeamCity. He also has vast knowledge in Linux, Splunk, ZenDesk, Postman and HTML.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Apr 01 2015

How to Test Image Upload Functionality With JMeter

Need to load test the upload image functionality of your web app? Don’t search through endless forum threads looking for help! I’d like to show you—step by step— how easily this can be done via JMeter. Let’s take a closer look:

 

Setting up the JMeter Script

 

First, make sure that your HTTP request is set to “POST” and the "Use multipart/form-data for POST" box is checked.

 

 

Here are a few important points to consider in the ‘Send Files With the Request’ window:

  • File path - If you test locally, make sure you give the full file path, including the file name. When using BlazeMeter, don’t add a path to the file, as it will automatically be placed in the jmeter/home/folder in the cloud
  • Parameter Name -  This must be the exact “name” attribute as it appears in the page source, otherwise the file won’t have a ‘destination.
  • Mime Type - It goes without saying, but make sure you enter the correct one. If not, the upload process won’t work properly.

 

Here’s a list of common Image Mime Types:

  • image/gif: GIF image

  • image/jpeg: JPEG JFIF image

  • image/png: PNG image

  • image/svg+xml: SVG vector image

  • image/tiff: TIF image

  • image/vnd.djvu: DjVu image and multi-page document format

 

Want to Upload Several Files?

 

To do this, you'll need to “parameterize” the script a bit. Instead of the image file name that you see in the ‘Send Files With the Request’ window above, you’ll need to write ${imageName}. Next, add a ‘CSV Data Set Config’ element to the top of the script. This will read the file names from a CSV file and set them in a variable called “imageName.”

 

For example:

 

image1.png,image2.png,image3.png

 

If you want every user to upload all the files only once, choose “False” at ‘Recycle on EOF’ and “True” at ‘Stop thread on EOF.’ Of course, deciding on how to configure every script depends on the specific scenario.

 

 

Want to Run This Test in BlazeMeter?

 

If you want to run tests in the cloud for extremely high traffic loads and from multiple geographical locations, you might already be using BlazeMeter.

 

If so, this is super easy to do. In order to upload files/images in your scenario, you’ll need to upload them along with your JMX and any additional file your scenario requires. You can also ZIP them all, upload the archive and set up a test in BlazeMeter.

 

 

Have some tips of your own to share? Be sure to let us know in the comments section below.

 

     
arrow Please enter a URL with http(s)

You might also find these useful:

Interested in writing for our Blog?Send us a pitch!