Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

drag n drop file upload react

<input
  onChange={onFileInputChange}
  ref={fileInputRef}
  type="file"
  className="hidden"
/>
Comment

drag n drop file upload react

<FileDrop
  onTargetClick={onTargetClick}
Comment

react-drag-drop-files open twice

//Put it in a function (worked for me)
function DragDrop() {
  const [file, setFile] = useState(null);
  const handleChange = file => {
    setFile(file);
  };
  return (
    <FileUploader 
        handleChange={handleChange} 
        name="file" 
    />
  );
}

//And call it e.g.
return (
	...
    <DragDrop/>
    ...
)
Comment

drag n drop file upload react

const fileInputRef = useRef(null);
Comment

drag n drop file upload react

const onFileInputChange = (event) => {
  const { files } = event.target;
  // do something with your files...
}
Comment

drag n drop file upload react

const onTargetClick = () => {
  fileInputRef.current.click()
}
Comment

drag n drop file upload react

nvm use # Probably optional, but it can't hurt

cd file-drop
npm install
npm start

cd demo
npm install
npm start
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript date objects 
Javascript :: how to change textContent in js 
Javascript :: combineReducers. 
Javascript :: Agora Video Calls 
Javascript :: conditional style react 
Javascript :: event handler 
Javascript :: notify js 
Javascript :: Change Title In React Project 
Javascript :: javascript var in quotes 
Javascript :: how to move an element to the cursor in javascript 
Javascript :: node api with mongodb 
Javascript :: set placeholder javascript 
Javascript :: javascript break out of map 
Javascript :: how to clear textbox in javascript 
Javascript :: nodejs grpc 
Javascript :: Promise.all() with async and await to run in console 
Javascript :: promise in js 
Javascript :: for in and for of in js 
Javascript :: http_proxy 
Javascript :: express winston 
Javascript :: react faq 
Javascript :: jaascript loop 
Javascript :: get js 
Javascript :: get the last element of array javascript 
Javascript :: .has js 
Javascript :: check items in array javascript 
Javascript :: What do "module.exports" and "exports.methods" mean in NodeJS / Express 
Javascript :: new file shortcut vscode 
Javascript :: usereducer react 
Javascript :: if touchend javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =