zeus999
Live View: How to Upload Files
While Uploading files with LiveView, is not returning %Plug.Upload{} struct in handle_event/3 function, instead it is returning string something like this "[object File]". Do I need to parse this string to get the struct or there is some different way to handle File uploading with LiveView.
Below is my code for reference.
<%= form_for @changeset, "#", [class: "add-candidate-form w-100", id: "applicant-form", multipart: true, phx_change: :validate, phx_submit: :save], fn f -> %>
<div class="form-group col-6">
<label>Resume <span class="text-danger">*</span></label>
<div class="input-group">
<div class="custom-file">
<%= file_input f, :resume, [class: "custom-file-input", id: "inputGroupFile01", file_input: "one"] %>
<label class="custom-file-label" for="">Max size 2 mb</label>
</div>
</div>
</div>
<% end %>
When not using LiveView, this is working fine and I am getting %Plug.Upload{} struct in the params on submitting the form.
Most Liked
kokolegorille
Hello and welcome,
I think it’s available now with Phoenix 1.5.7 which includes phoenix_live_view 0.15 ![]()
wmnnd
If I remember @chrismccord’s keynote at Elixirconf EU earlier this month, file upload is still a feature on their to-do list.
Also: Explore image uploads · Issue #104 · phoenixframework/phoenix_live_view · GitHub
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









