# Get a filename from a form-data request body field

**URL:** <https://community.postman.com/t/get-a-filename-from-a-form-data-request-body-field/34341>\
**Category:** Help Hub\
**Created:** [April 8, 2022, 1:18pm UTC](https://community.postman.com/t/get-a-filename-from-a-form-data-request-body-field/34341 "2022-04-08T13:18:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwahahahaxyz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/mwahahahaxyz/32/11685_2.png) [@mwahahahaxyz](https://community.postman.com/u/mwahahahaxyz)\
**Post date:** [April 8, 2022, 1:18pm UTC](https://community.postman.com/t/get-a-filename-from-a-form-data-request-body-field/34341/1 "2022-04-08T13:18:35Z")

</div>

Hi,

To upload a file, my API needs a POST request with the following fields filled out correctly:

- file\_name: the name of the file once in the repository,
- file\_content: the binary content of the file.

This is how I write it in cURL :  
`curl https://{{url_api}}/entite/{{entity}}/document/{{document_id}}/file/fichier_metadata -X POST -F file_name=metadata.json -F file_content=@"files\metadata.json"`

I was able to do the same in Postman using a form-data body:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/a/a17f7197ae76211853c6ff1b5eccf330099fa5ef.png)

It works perfectly fine. However, is there any way to avoid manually entering the “file\_name” field value? I’d like Postman to fill this field with the name of the file I’ve selected in the “file\_content” field.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 3, 2025, 9:44am UTC](https://community.postman.com/t/get-a-filename-from-a-form-data-request-body-field/34341/2 "2025-04-03T09:44:22Z")

</div>

Closed on April 3, 2025, 9:44am UTC

We’re closing out older posts with no replies to keep the community organized. If you still need help with this issue, feel free to post a new topic or reply here to reopen.

You can paste the curl command directly into the URL bar and it will create the request for you with the specified values. You could also create a local variable for the filename and write a pre-request script to populate the `file_name` based on the `file_content` name using some regex.
