input type=file, file upload control
inputFile
A simple file selector, like this: .
Setting the 'href', 'text' or a 'thumbnail' setting for inputFile is just for creating a clickable link to the file (it helps creating user-friendly forms with a delete file button and some image preview).
This control aborts with an error message if file upload is
not allowed by php.ini (file_uploads=0).
You may use the 'binaryvalue' setting (set to 1) to get the binary file contents returned by any of the clonefish methods (getElementValue(), getValues() ) after a successful validation. Further notes:
- The contents of the uploaded file is loaded
from the
$_FILES['inputname']['tmp_name']file. - The
nullPHP value is returned by the value-returing-methods after submitting an invalid file (not, since that would be a one-byte long value which is misleading).false - If you've set the 'value' attribute of the file input previously, it'll be overwritten if an invalid file was submitted.
- Live examples:
- Definition:
<?php $config = Array( 'portrait' => Array( 'type' => 'inputFile', 'displayname' => 'Choose a picture', // optional settings 'href' => 'http://www.example.com/uploaded/images/12.gif', 'text' => 'click here to download the current file', 'thumbnail' => 'http://www.example.com/uploaded/images/thumbs/12.gif', 'delete' => 'somescript.php?target=delete&filename=something.gif', // layout settings 'thumbnaillayout' => '<img src="%thumbnail%" border="0" alt="%text%">', 'linklayout' => '<a target="_blank" href="%href%">%thumbortext%</A><BR>', 'deletelayout' => '<br><input type="button" value="' . STR_IMAGE_DELETE . '" onclick="location.href='%delete%';" />'; // misc 'binaryvalue' => '1 | 0', // default: 0 ); ?> - Possible validators:
- 'file'
- 'custom'
