Check file size before uploading it in React Uploader component (2024)

30 Jan 20233 minutes to read

By using the uploading event, you can get the file size before uploading it to the server.
File object contains the file size in bytes only. You can convert the size to standard formats (KB or MB) using bytesToSize method.

import { UploaderComponent } from '@syncfusion/ej2-react-inputs';import * as React from 'react';import * as ReactDOM from "react-dom";export default class App extends React.Component { uploadObj; path = { removeUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Remove', saveUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Save' }; onBeforeUpload(args) { // get the file size in bytes const sizeInBytes = args.fileData.size; // get the file size in standard format alert("File size is: " + this.uploadObj.bytesToSize(sizeInBytes)); } render() { return (<UploaderComponent autoUpload={false} ref={upload => { this.uploadObj = upload; }} asyncSettings={this.path} uploading={this.onBeforeUpload = this.onBeforeUpload.bind(this)}/>); }}ReactDOM.render(<App />, document.getElementById('fileupload'));
import { UploaderComponent, UploadingEventArgs } from '@syncfusion/ej2-react-inputs';import * as React from 'react';import * as ReactDOM from "react-dom";export default class App extends React.Component<{}, {}> { public uploadObj: UploaderComponent; public path: object = { removeUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Remove', saveUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Save' } public onBeforeUpload(args: UploadingEventArgs): void { // get the file size in bytes const sizeInBytes: number = args.fileData.size; // get the file size in standard format alert("File size is: " + this.uploadObj.bytesToSize(sizeInBytes)); } public render(): JSX.Element { return ( <UploaderComponent autoUpload={false} ref = {upload => {this.uploadObj = upload !}} asyncSettings={this.path} uploading={this.onBeforeUpload = this.onBeforeUpload.bind(this)} /> ); }}ReactDOM.render(<App />, document.getElementById('fileupload'));

You can also explore React File Upload feature tour page for its groundbreaking features. You can also explore our React File Upload example to understand how to browse the files which you want to upload to the server.

Check file size before uploading it in React Uploader component (2024)
Top Articles
50+ Epic Stocking Stuffers for Teenage Boys (That They Actually Want This Year)
Investment Property 101: How to Find, Hold, and Build Wealth in Real Estate
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 5861

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.