Fork me on GitHub

Example: Basic file field creation

How to create a file field.

File upload

To create a file upload form, you must use the "file" field within a form with the enctype attribute set to 'multipart/form-data'.

HTML

<div id="field-container"></div>

JavaScript

Implementation

YUI().use('inputex-file', 'inputex-form', 'inputex-timeinterval', function(Y) {

    Y.inputEx({
        type: 'form',
        parentEl: 'container1',
        enctype: 'multipart/form-data',
        action: 'input_file.php',
        fields: [
            {type: 'file', name: 'textFile', label:'Search file', accept: 'text/*', size: 50 }
        ],
        buttons: [
            {type: 'submit', value: 'Upload'}
        ]
    });

});