Тёмный

Upload Files in React - Typescript, Drag and Drop, & Form Examples 

Colby Fayock
Подписаться 27 тыс.
Просмотров 48 тыс.
50% 1

Learn how to upload files like images from a form with drag and drop in a React app.
We'll walk through setting up an HTML filepicker input to select files, read the files and show a preview using the Filereader API, uploading them to services like Cloudinary, configuring the file input to accept only certain types, and seeing how we can easily add drag and drop with React Dropzone.
Dig deeper into Full Stack React with my upcoming Appwrite course: spacejelly.dev/reactappwrite
🧰 Resources
Tutorial: spacejelly.dev/posts/uploadin...
Starter: github.com/colbyfayock/demo-r...
Code: github.com/colbyfayock/my-rea...
Demo: my-react-file-upload.vercel.app/
react-dropzone.js.org/
📺 RU-vid: ru-vid.com?sub_c...
🐦 Twitter: / colbyfayock
📹 Twitch: / colbyfayock
✉️ Newsletter: www.colbyfayock.com/newsletter/
🎥 What I Use: www.colbyfayock.com/uses
#colbyfayock #reactjs #uploadfile #draganddrop #webdevelopment

Наука

Опубликовано:

 

26 июл 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@tastymuffinmm
@tastymuffinmm 9 месяцев назад
Super helpful tutorial, straight to the point and good examples. Subscribed and looking forward to more!
@colbyfayock
@colbyfayock 9 месяцев назад
thank you!! 🙌
@ChesterRivas
@ChesterRivas 7 месяцев назад
Your tutorials are always solid and getting better. Thank you sir.
@colbyfayock
@colbyfayock 7 месяцев назад
appreciate the kind words!
@Brlitzkreig
@Brlitzkreig Месяц назад
Wow, you're an excellent teacher you explain it so concisely
@colbyfayock
@colbyfayock 29 дней назад
thank you🙏
@andinuruljihad2912
@andinuruljihad2912 8 месяцев назад
great tutorial. i will watch your youtube career with great interest.
@colbyfayock
@colbyfayock 8 месяцев назад
thank you!
@yourlinuxguy
@yourlinuxguy 2 месяца назад
Amazing tutorial, Thankyou so much.
@colbyfayock
@colbyfayock 2 месяца назад
thanks and no problem!
@peapuffer3514
@peapuffer3514 10 месяцев назад
What's up buddy.😊 Watching your video after a while. Keep it up
@colbyfayock
@colbyfayock 10 месяцев назад
thank you!
@leonardozerino9628
@leonardozerino9628 2 месяца назад
Great video my dude, thank you so much.
@colbyfayock
@colbyfayock 2 месяца назад
no problem!
@raminkhodaie4063
@raminkhodaie4063 6 месяцев назад
very insightful video
@colbyfayock
@colbyfayock 6 месяцев назад
glad it was helpful!
@techcoderuz
@techcoderuz Месяц назад
thanks. Great tutorial
@colbyfayock
@colbyfayock Месяц назад
🙌
@John-eq5cd
@John-eq5cd 4 месяца назад
Another clear and useful video, thanks! A couple of questions, though... Do we need our Cloudinary api_key to upload assets? I can successfully do this using the Cloudinary url and referencing my cloud name in the url, nothing else needed. Secondly, by using NEXT_PUBLIC_ in front of your environment variable as you suggest below, is this not exposing that env variable?
@colbyfayock
@colbyfayock 4 месяца назад
you need the API key unless you're doing an unsigned upload which is defined using an Upload Presset yup, that exposes it to the client, but the API Key is okay for this use, you do _not_ want to expose the API Secret
@ruairidhgrass3479
@ruairidhgrass3479 9 месяцев назад
Thanks man, how did you get an environment variable in a client component? It's giving me an error,
@colbyfayock
@colbyfayock 9 месяцев назад
no problem! you prepend VITE_ if youre using React with Vite to make it public: github.com/colbyfayock/my-react-file-upload/blob/main/src/pages/contact.tsx#L42
@ruairidhgrass3479
@ruairidhgrass3479 9 месяцев назад
@@colbyfayock thanks for the quick reply man, sorry I should have specified. I’m using nextjs on my project
@colbyfayock
@colbyfayock 9 месяцев назад
@@ruairidhgrass3479np, similarly you'd want to add NEXT_PUBLIC_ in front of your environment variable then
@davidsehi7109
@davidsehi7109 10 месяцев назад
Thanks man
@colbyfayock
@colbyfayock 10 месяцев назад
No problem!
@blank.haruka
@blank.haruka 5 месяцев назад
Thank you sm!
@colbyfayock
@colbyfayock 5 месяцев назад
no problem!
@vikashmishra7160
@vikashmishra7160 5 месяцев назад
@8:55 src={preview} was showing error .. how did you resolve it?
@colbyfayock
@colbyfayock 5 месяцев назад
added src={preview as string} github.com/colbyfayock/my-react-file-upload/blob/main/src/pages/contact.tsx#L90
@colbyfayock
@colbyfayock 10 месяцев назад
Dig deeper into React with my course Full Stack React with Appwrite: spacejelly.dev/reactappwrite Otherwise get fresh tutorials and other free content straight to your inbox! colbyfayock.com/news
@PelleWidell
@PelleWidell 5 месяцев назад
Very good video. But what if I want to paste a snippet from memory?
@colbyfayock
@colbyfayock 5 месяцев назад
hey thanks! good question, did a quick lookup and this codepen seems to work, check the web console upon paste: codepen.io/appsoftware/pen/WNwWpzW this would make for a good tutorial! will add it to my list
@crypto1886
@crypto1886 2 месяца назад
Hey dude great video, I am a newbie in react and javascript and am running into an error in this line of code: const { acceptedFiles, getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop }); Error: Type '(acceptedFiles: FileList) => void' is not assignable to type '(acceptedFiles: T[], fileRejections: FileRejection[], event: DropEvent) => void'. Types of parameters 'acceptedFiles' and 'acceptedFiles' are incompatible. Property 'item' is missing in type 'T[]' but required in type 'FileList'.ts(2322) lib.dom.d.ts(8330, 5): 'item' is declared here. Any clue how to fix this?
@colbyfayock
@colbyfayock 2 месяца назад
hey have you seen my code for how i set it up? github.com/colbyfayock/my-react-file-upload/blob/main/src/pages/contact.tsx i just spun it up and dont see any errors with that, perhaps its an issue with how you have onDrop set up, where i see FileList, are you using FileList instead of Array perhaps?
@shreyaishere6783
@shreyaishere6783 6 месяцев назад
If we want a pdf or doc file instead of image?
@colbyfayock
@colbyfayock 6 месяцев назад
have you tried? it should work the same as long as you're not restricting the filetype
@abderrahmaneelfilali5933
@abderrahmaneelfilali5933 6 месяцев назад
suuper helpful
@colbyfayock
@colbyfayock 6 месяцев назад
🙌
@user-yj2hz4mp4h
@user-yj2hz4mp4h 6 месяцев назад
can you make a video showing how to do this one by one, step by step from scratch?
@salijoghli
@salijoghli 5 месяцев назад
Bro he literally did that
@user-yj2hz4mp4h
@user-yj2hz4mp4h 5 месяцев назад
@@salijoghli let me rewatch it and comment again
Далее
Drag and dropping files in React using react-dropzone
26:26
React JS: Uploading Files with DRAG and DROP API
7:34
ИМПРОВИЗАТОРЫ | Нам 8 лет
1:57:59
Просмотров 366 тыс.
ATEEZ(에이티즈) - 'WORK' Official MV
03:15
Просмотров 11 млн
Загрузка файлов с фронтенда
18:49
How to create a CSS navigation bar in 6 minutes! 🧭
6:28
The Last React File Input You'll Ever Need
7:44
Просмотров 11 тыс.
Laravel First Impressions From A JavaScript Dev
21:08
Просмотров 114 тыс.
This React Drag and Drop Component Is Magic
9:56
Просмотров 73 тыс.
TypeScript in React - COMPLETE Tutorial (Crash Course)
53:21
Node.js File Upload API with Express Tutorial
35:25
Просмотров 63 тыс.
Плохие и хорошие видеокарты
1:00
Карточка Зарядка 📱 ( @ArshSoni )
0:23
How charged your battery?
0:14
Просмотров 2,5 млн