# File-uploads as part of a Collection run

**URL:** <https://community.postman.com/t/file-uploads-as-part-of-a-collection-run/4578>\
**Category:** Help Hub\
**Tags:** faq\
**Created:** [March 15, 2019, 6:55pm UTC](https://community.postman.com/t/file-uploads-as-part-of-a-collection-run/4578 "2019-03-15T18:55:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-paul](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/john-paul/32/919_2.png) [@john-paul](https://community.postman.com/u/john-paul)\
**Post date:** [March 15, 2019, 6:55pm UTC](https://community.postman.com/t/file-uploads-as-part-of-a-collection-run/4578/1 "2019-03-15T18:55:19Z")

</div>

For individual requests, you can simply set the body type to `form-data` ​, select a file, and send the request. Unfortunately, if you’re sending the same request as part of a Collection run, it’s a little more difficult than we’d like it to be at the moment. There’s an [open feature request](https://github.com/postmanlabs/postman-app-support/issues/4320) we’re working on to make it easier, but for now the recommended process is to use [Newman](https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/), as follows:

1. In Postman, [set the body type for your request](https://learning.getpostman.com/docs/postman/sending_api_requests/requests/#form-data) to `form-data` . Add a key, and select `File` ​ as the type:  
​

2. When you’re done working on your Collection, [export it as a .JSON file](https://learning.getpostman.com/docs/postman/collections/data_formats/#collections) so that it can be run with Newman

3. Open the Collection you exported as a .JSON file, and search for the form-data key you created for your file upload. Look for the `"src"` property (it will be empty), and add the file path there:

```auto
{
"key":"your_key_here",
"type":"file",
"src": "" // <----- example: "src":"c:\\users\\files\\file.txt"
},

```

_**Please note that on Windows, you’ll need to make all backslashes in the file path doubled (as shown above), so that the JSON parses correctly.**_

1. [Install Newman](https://github.com/postmanlabs/newman#getting-started) (if you haven’t already)

2. [Run the Collection using Newman](https://github.com/postmanlabs/newman#usage)

Please let us know if you have any additional questions, get stuck, or if you have suggestions on improvements!

---

<div class="post-metadata">

**Author:** ![jdz100](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jdz100](https://community.postman.com/u/jdz100)\
**Post date:** [February 27, 2023, 11:36am UTC](https://community.postman.com/t/file-uploads-as-part-of-a-collection-run/4578/2 "2023-02-27T11:36:21Z")

</div>

> [@jdz100](#):
>
> > [@john-paul](#):
> >
> > `\\`
> 
> I don’t think this works anymore. Newman isn’t giving any indications of a failed run:
> 
> ┌─────────────────────────┬─────────────────────┬─────────────────────┐  
> │ │ executed │ failed │  
> ├─────────────────────────┼─────────────────────┼─────────────────────┤  
> │ iterations │ 1 │ 0 │  
> ├─────────────────────────┼─────────────────────┼─────────────────────┤  
> │ requests │ 1 │ 0 │  
> ├─────────────────────────┼─────────────────────┼─────────────────────┤  
> │ test-scripts │ 0 │ 0 │  
> ├─────────────────────────┼─────────────────────┼─────────────────────┤  
> │ prerequest-scripts │ 0 │ 0 │  
> ├─────────────────────────┼─────────────────────┼─────────────────────┤  
> │ assertions │ 0 │ 0 │  
> ├─────────────────────────┴─────────────────────┴─────────────────────┤  
> │ total run duration: 2s │  
> ├─────────────────────────────────────────────────────────────────────┤  
> │ total data received: 70B (approx) │  
> ├─────────────────────────────────────────────────────────────────────┤  
> │ average response time: 1922ms [min: 1922ms, max: 1922ms, s.d.: 0µs] │  
> └─────────────────────────────────────────────────────────────────────┘
> 
> But the photo I’m trying to upload with newman using this method is not uploaded.

False alarm: the reason it didn’t work is because I didn’t allow Postman to use files outside of my working directory  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/5/755838320a37e816f9fbc83060992f311a58d327.png)

When I moved the files to the working directory, it worked. It was just a bit frustrating that there was no informative error message so it took me ages to figure out.
