Uploading Files with Blazor (Server & WebAssembly)
Vložit
- čas přidán 19. 06. 2024
- Today, we start directly within Visual Studio because I want to show you how to upload files in Blazor web applications.
00:00 Introduction
00:07 Component Template using InputFile
00:42 Handling the OnChange of an InputFile component
02:05 Saving the File on a Local Disk
03:03 Running and Testing the Application
03:59 Uploading multiple Files
04:58 File Upload Best Practices
05:26 Blazor Server vs. Blazor WebAssembly
06:40 Conclusion
📌 File Upload Cheat Sheet (OWASP)
cheatsheetseries.owasp.org/ch...
🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
claudiobernasconi.ch/dotnet-c...
📌 .NET Developer Roadmap
claudiobernasconi.ch/learn-do...
📌 CZcams Playlists:
The FREE Blazor Crash Course: • The FREE Blazor Crash ...
Blazor: • Blazor
✅ SUBSCRIBE FOR MORE VIDEOS
Subscribe: 🔔 claudiobernasconi.ch/Subscribe
🚀 CONNECT & SUPPORT
Twitter: / chbernasconic
Blog: claudiobernasconi.ch
Newsletter: claudiobernasconi.ch/newsletter
* Affiliate Link: I earn a small commission at no additional cost - Věda a technologie
These are the tutorials I like.
I would also make a video for uploading files to chunk to a minimal api
Thanks.
Thanks for the content! I have a question. Is this a good solution to upload files up to 5Gb?
Great question. It depends on how you want to handle the file upload in your backend. You almost always want to stream data with a size like this. You do not want to have a 5 GB file in your server's memory at any time. Yes, you can select files up to that size client-side, but make sure to educate yourself on how to handle it server-side. Also, uploading a 5 GB file through a web interface might not be a great idea in general. Keep in mind that depending on the user's Internet connection the upload can take a very long time. There is no retry or continue option. FTP or an app on your user's device might give you more options/control.
Is this Blazor web app in .Net 8, if not how can we do it by selecting auto (server and webassembly )
It's .NET 7, but you should be able to use the same code depending on what interactivity mode you want. Do you have a specific question? I currently don't plan to rerecord the video for .NET 8 because I think it should be transferable from this video. Happy to help if you have any specific questions.
Seems like this still does not work in Firefox. I'll never understand the point of creating a great control like if it's not goiing to work with major browsers??
Thanks for your feedback. I just tried it myself with Firefox 119.0.1 (on Windows) and it works for me. It would not be ideal if it wasn't working in Firefox, I agree.
I tried your example here and it is running without error but I don't find the targetPath on my computer.
randomFile give me this: "/tmp/tmpIlKfaD.tmp". But where is this tmp-dir?
Using windows 10 with Blazor Webassembly .NET 6 in a Client/Server/Shared structure
Open a Windows console and insert the command "%temp%" without the quotation marks. It should return the path to your temp directory.
@@ClaudioBernasconi Ok. For me it says "C:\TEMP" (changed it in the registry for easier to find) but there are no files showing. I have my razor-page in the client-project. Maybe therefore?