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 :: jquery from js 
Javascript :: postgresql json array contains 
Javascript :: random string javascript 
Javascript :: rating 
Javascript :: validate decimal number with 6 decimal digits javascript 
Javascript :: react hook from 
Javascript :: break in javascript 
Javascript :: react native update helper 
Javascript :: background image react 
Javascript :: add property with value in js 
Javascript :: new function javascript 
Javascript :: .default in javascript 
Javascript :: chrome dev tools console api 
Javascript :: use ref in component reactjs 
Javascript :: javascript factorial stack 
Javascript :: formatt json to create node and child node react 
Javascript :: npm request cancel 
Javascript :: javascript nested objects 
Javascript :: You are getting a `numbers` array. Return the sum of **negative** numbers only. //condition to check for negative 
Javascript :: angular ngbtooltip z-index 
Javascript :: i need to keep track of quantity in inventory using JavaScript backend 
Javascript :: get all visible text on website javascript 
Javascript :: get number of elements in hashmap javascript 
Javascript :: click on list item javascript highlight 
Javascript :: check if item is already registered in angular angularfire site:stackoverflow.com 
Javascript :: nodejs postgresql scalar query 
Javascript :: how to get only citnames in google maps api js 
Javascript :: processing map in javascript 
Javascript :: iron_to_nugget.json 
Javascript :: how to print more than 20 documents mongo shell 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =