question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using b-form-file to upload an image, is it possible to preview the image prior to uploading it?

See original GitHub issue

I’m making an ‘avatar upload’ using b-form-file and would like to show a preview of the selected image before it’s sent to the server.

https://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded provides some possible answers but I was hoping there may be an easier way, perhaps this functionality is already baked-in but I couldn’t find a mention of it in the docs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jacobmllr95commented, Nov 13, 2019
1reaction
tmorehousecommented, Nov 13, 2019

@vesper8 Note you might have issues with really large images and some browsers which have a limit on the length of a data URI in the <img> src attribute.

But basically you can use the same method @jackmu95 provided to read the image file, but then pass the image to a <canvas> to process the file and scale it down in dimensions to get a “thumbnail” image as a data URI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload files in ASP.NET Core - Microsoft Learn
Files uploaded using the IFormFile technique are buffered in memory or on disk on the server before processing. Inside the action method, ...
Read more >
Determine if uploaded file is image (any format) on MVC
In case it can helps anyone, Here is a static method for HttpPostedFileBase that checks if a given uploaded file is an image:...
Read more >
Uploading a File using IFormFile Should Show an ... - GitHub
I am using IFormFile in the following action method to upload a file to my API. This causes the Swagger UI to display...
Read more >
File Upload in ASP.NET Core 6 - Detailed Guide
In this article, let's learn about how to perform file upload in ASP.NET Core 6. The file for upload can be of any...
Read more >
File Upload in ASP.NET Core MVC - Code Maze
In this article we are going to learn how to upload a file or multiple files in ASP.NET Core MVC application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found