34 lines
897 B
JavaScript
34 lines
897 B
JavaScript
|
|
import React, { useState } from 'react';
|
|
import {Form,Button} from "react-bootstrap";
|
|
|
|
|
|
function fileValidation(){
|
|
var fileInput = document.getElementById('file');
|
|
var filePath = fileInput.value;
|
|
var allowedExtensions = /(.csv)$/i;
|
|
if(!allowedExtensions.exec(filePath)){
|
|
alert('Please upload file having extensions .csv only.');
|
|
fileInput.value = '';
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function SubirArchivo(){
|
|
|
|
return(
|
|
<Form>
|
|
<Form.Group controlId="formFileLg" className="mb-3" size="lg">
|
|
<Form.Control type="file" id="file" size="lg" onChange={() => fileValidation()}/>
|
|
</Form.Group>
|
|
<p className="text-center">
|
|
<Button variant="primary" type="submit" size="lg">
|
|
Submit
|
|
</Button>
|
|
</p>
|
|
</Form>
|
|
);
|
|
}
|
|
export default SubirArchivo; |