Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
How to print the name of the file uploaded in react antd?

I am new to react and learning about files. I tried using a variable('filename' in the code) to store the name of the file when the file gets uploaded and print it in the first line of the code shown below but that wasn't working. I am not sure where I am going wrong. This is the basic code I wrote:

<Row> File name: {filename} </Row>
<Row>
  <Form.item name="fileupload"> 
    <Upload name="file" maxCount={1} showUploadList={false} accept=".png" beforeUpload={()=>false}>
      <Button type='primary'> Upload </Button>
    </Upload> 
  </Form>
</Row>

I want to print the name of the file uploaded in the first line. Am I doing it correctly and if so how do I print the uploaded file name over there?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In the onChange handler you'll get the information of the file that is uploaded.

handleFileUpload Function:

const handleFileUpload = (info) => {
  console.log(`File name: ${info.file.name}`)
  // Logic of action you want to perform on file upload
}

Add onChange:

<Row> File name: {filename} </Row>
<Row>
  <Form.item name="fileupload"> 
    <Upload name="file" maxCount={1} showUploadList={false} accept=".png" beforeUpload={()=>false} onChange={handleFileUpload} >
      <Button type='primary'> Upload </Button>
    </Upload> 
  </Form>
</Row>

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!