How can I help you?
Hide default drop area in React Uploader component
21 Feb 20265 minutes to read
Hide the default drag-and-drop area by overriding the corresponding Uploader styles. This is useful when you want to create a custom drop area or use the Uploader with alternative UI patterns. Override the following styles to hide the default drop area:
* .e-upload.e-control
* .e-upload .e-file-select
* .e-upload .e-file-drop
import * as React from 'react';
import * as ReactDOM from "react-dom";
import { UploaderComponent } from '@syncfusion/ej2-react-inputs';
export default class App extends React.Component {
// Uploader component
uploadObj;
path = {
removeUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Remove',
saveUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Save'
};
dropAreaRef;
onCreated() {
this.uploadObj.dropArea = this.dropAreaRef;
this.uploadObj.dataBind();
}
render() {
return (<div className='control-pane'>
<div className='control-section row uploadpreview' ref={dropAreaEle => this.dropAreaRef = dropAreaEle}>
<div className='col-lg-9'>
<div className='upload_wrapper'>
{/* Render Uploader */}
<UploaderComponent id='fileUpload' type='file' ref={upload => { this.uploadObj = upload; }} asyncSettings={this.path} created={this.onCreated = this.onCreated.bind(this)}/>
</div>
</div>
</div>
</div>);
}
}
ReactDOM.render(<App />, document.getElementById('fileupload'));import * as React from 'react';
import * as ReactDOM from "react-dom";
import { UploaderComponent } from '@syncfusion/ej2-react-inputs';
export default class App extends React.Component<{}, {}> {
// Uploader 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'
}
private dropAreaRef: HTMLElement;
public onCreated(): void {
this.uploadObj.dropArea = this.dropAreaRef;
this.uploadObj.dataBind();
}
public render(): JSX.Element {
return (
<div className = 'control-pane'>
<div className='control-section row uploadpreview' ref={dropAreaEle => this.dropAreaRef = dropAreaEle!}>
<div className='col-lg-9'>
<div className='upload_wrapper'>
{/* Render Uploader */}
<UploaderComponent id='fileUpload' type='file' ref = {upload => {this.uploadObj = upload !}}
asyncSettings = {this.path} created={this.onCreated = this.onCreated.bind(this)}
/>
</div>
</div>
</div>
</div>
)
}
}
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.