# Upload file in POST request

**URL:** <https://community.gatling.io/t/upload-file-in-post-request/5317>\
**Category:** Gatling (Open-Source)\
**Created:** [October 24, 2019, 9:29am UTC](https://community.gatling.io/t/upload-file-in-post-request/5317 "2019-10-24T09:29:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Obrocki](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Jakub\_Obrocki](https://community.gatling.io/u/Jakub_Obrocki)\
**Post date:** [October 24, 2019, 9:29am UTC](https://community.gatling.io/t/upload-file-in-post-request/5317/1 "2019-10-24T09:29:20Z")

</div>

Hi, I have problem with uploading files from my script, here are two screenshots from Fiddler when I upload file via browser:

 ![web_fiddler.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/84e56d97be547b5ee19930758d66f57ae3b72581.png)

 ![web_fiddler2.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/cbbed3e8ab9cd55e6ff802cb98b9734e837e1460.png)

And here are when I run gatling

 ![gatling_fiddler.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/7791308faaf8145b5d54d85fcb03c77e794e826c.png)

 ![gatling_fiddler2.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/b8fdbc51154c0c9fef6587994696a6566fbc55e1.png)

Here are code fragments with header Map and the request when I teoratically upload file:

`.exec(http("request_30") .options("/api/media/images") .headers(headers_30) .resources(http("request_31") .post("/api/media/images") .check(regex("""[\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12}""").find.saveAs("photoId")) .headers(headers_31) .body(RawFileBody("recordedsimulation/0031_request.dat")))) .exec(http("request_32") .get("/UploadedFiles/${photoId}.png") .headers(headers_9))`

`  
val headers\_30 = Map(  
“Access-Control-Request-Headers” → “authorization”,  
“Access-Control-Request-Method” → “POST”,  
“Origin” → “[https://frontend.iteodev.com](https://frontend.iteodev.com)”,  
“Sec-Fetch-Mode” → “cors”)

val headers\_31 = Map(  
“Accept” → “application/json, text/plain, _/_”,  
“Accept-Enconding” → “gzip, deflate, br”,  
“Content-Type” → “multipart/form-data; boundary=----WebKitFormBoundarycByzqwKAVKTwQR0H”,  
“Origin” → “[https://frontend.iteodev.com](https://frontend.iteodev.com)”,  
“Sec-Fetch-Mode” → “cors”,  
“authorization” → “Bearer ${authToken}”)

`

And the content of .dat file

`------WebKitFormBoundarycByzqwKAVKTwQR0H Content-Disposition: form-data; name="file"; filename="photo.png" Content-Type: image/png`

What should I add or change to upload my file? Thanks in advance
