Last active
August 29, 2015 14:23
-
-
Save davorpeic/dbd24b82c9fde5b73fe4 to your computer and use it in GitHub Desktop.
Single file upload for Assets in Channel Form - ExpressionEngine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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