Hi everyone,
I am using LiveView file uploading which is working awesome. but when I deploy my server if someone uploading files, it stop uploading. So i am trying to use phx-auto-recover. When i restart server it try to recover last state of form. But due to different file upload reference facing this error.
Here is my code:
@upload_options [
accept: ~w(.jpg .jpeg .png image/jpeg image/png),
max_entries: 5,
max_file_size: 4857600,
auto_upload: true
]
def mount(_params, _session, socket) do
{
:ok,
socket
|> assign(:uploaded_files, [])
|> allow_upload(:photo, @upload_options)
}
end
@impl true
def handle_event("recover_upload", params, socket) do
IO.inspect params
IO.inspect(socket)
{:noreply, socket}
end
@impl true
def handle_event("upload", _params, socket) do
socket
|> process_photos()
{:noreply, socket}
end
I am expecting it should execute recover_upload but it is not. it is throwing error before reaching to this function.
<form id="form" phx-submit="save" phx-change="upload" phx-auto-recover="recover_upload">
<div class="file_upload">
<%= live_file_input @uploads.photo %>
</div>
</form>
Thanks in Advance