Skip to content

Instantly share code, notes, and snippets.

@davorpeic
Last active August 29, 2015 14:23
Show Gist options
  • Save davorpeic/dbd24b82c9fde5b73fe4 to your computer and use it in GitHub Desktop.
Save davorpeic/dbd24b82c9fde5b73fe4 to your computer and use it in GitHub Desktop.
Single file upload for Assets in Channel Form - ExpressionEngine
// So, I had a need to disable File browser that Assets comes with in frontend,
// and use simple file input
// Official docs are ok, but not complete
// http://docs.pixelandtonic.com/assets/templating/channel_form.html#using-a-file-input
// Lets say your fieldtype is called 'assets_test'
// This part is needed so we can 'reset' our field before the upload
{if '{assets_test:total_files}' > 0}
{assets_test}
<input type="hidden" name="assets_test[]" value="{file_id}" />
{/assets_test}
{if:else}
<input type="hidden" name="assets_test" value="NULL" />
{/if}
<input type="file" name="assets_test[]" multiple="multiple" />
// Use _filedir for local storage as mention in the official docs
<input type="hidden" name="assets_test_source" value="1" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment