EPISODE · Apr 2, 2024 · 5 MIN
Advanced htmx: hx-encoding
from hx-pod · host Lazarus
An amazingly simple file uploading form *with a progress bar* using htmx:<form id='form' hx-encoding='multipart/form-data' hx-post='/[where-you-want-post-it]' hx-target='#target-div'> <input type="hidden" name="_token" value="" /> <input type='file' name='file'> <button> Upload </button> <progress id='progress' value='0' max='100'></progress></form><script> htmx.on('#form', 'htmx:xhr:progress', function(evt) { htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100) });</script>
What this episode covers
An amazingly simple file uploading form *with a progress bar* using htmx:<form id='form' hx-encoding='multipart/form-data' hx-post='/[where-you-want-post-it]' hx-target='#target-div'> <input type="hidden" name="_token" value="" /> <input type='file' name='file'> <button> Upload </button> <progress id='progress' value='0' max='100'></progress></form><script> htmx.on('#form', 'htmx:xhr:progress', function(evt) { htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100) });</script>
NOW PLAYING
Advanced htmx: hx-encoding
No transcript for this episode yet
Similar Episodes
Mar 14, 2026 ·23m
Mar 11, 2026 ·16m
Feb 28, 2026 ·14m