zeus999

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

kokolegorille

Hello and welcome,

I think it’s available now with Phoenix 1.5.7 which includes phoenix_live_view 0.15 :slight_smile:

wmnnd

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

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement