import React from "react"; import {useState, useEffect} from 'react' import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import LinearProgress from '@mui/material/LinearProgress'; import { Box, Typography, Button } from '@mui/material'; import axios from 'axios'; const baseURL = "http://localhost:8000/api" const Input = styled('input')({ display: 'none', }); function LinearProgressWithLabel(props) { return ( {`${Math.round( props.value, )}%`} ); } LinearProgressWithLabel.propTypes = { /** * The value of the progress indicator for the determinate and buffer variants. * Value between 0 and 100. */ value: PropTypes.number.isRequired, }; const UploadFiles = (props) => { const { apiURL, fileName, buttonText, applyBinarize, debug } = props; const [progress, setProgress] = useState(0); const [uploadFile, setUploadFile] = useState(0); const handleUploadSelection = (e) => { console.log(e.target.files[0]) setUploadFile(e.target.files[0]); }; const handleUpload = (event) => { event.preventDefault() const formData = new FormData(); console.log(uploadFile) formData.append("fileTitle", fileName); formData.append("applyBinarize", applyBinarize); formData.append("debug", debug); formData.append("uploadedFile", uploadFile); axios.post(baseURL+apiURL, formData, { headers: { 'content-type': 'multipart/form-data' } }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); }; return(
) } export default UploadFiles