Inertia Reactjs | drozone uploader not sending file to server

Viewed 13

hi i am using react dropzone uploader for image uploading below is my code

import "react-dropzone-uploader/dist/styles.css";
import Dropzone from "react-dropzone-uploader";
import { Inertia } from '@inertiajs/inertia'

const SetDropZone = ({id}) => {
    const getUploadParams = () => {
      return { url: 'https://httpbin.org/post' }
    }
  
    const handleChangeStatus = ({ meta }, status) => {
        
        if(status == 'done'){
            let formData = new FormData();
            formData.append('file', meta);  
             //sending file to server
            Inertia.post(id, formData, { 
                forceFormData: true,
              })
        }

    }
  
    return (
      <Dropzone
        getUploadParams={getUploadParams}
        onChangeStatus={handleChangeStatus}
        styles={{ dropzone: { minHeight: 300, maxHeight: 300 } }}
      />
    )
  }

  export default SetDropZone

when i try to get file in controller via $request->hasFile('file'), then i am getting false.

0 Answers
Related