Skip to content

Is it possible to change the file name to the input field name? #934

Closed Answered by dasveloper
dasveloper asked this question in Q&A
Discussion options

You must be logged in to vote

Nevermind I figured it out! The form field name is available under part when setting a custom file name under the filename options. So you can rename the file to the field name and keep the extension like this.

const form = formidable({
  keepExtensions: true,
  filename: (_, ext, part) => {
    return part.name + ext;
  },
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dasveloper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant