File
This is not a standard file input field. This is the default ImpressPages file upload field that comes with its JavaScript and server side to handle multiple uploads and secure uploaded files. Use it to provide a great experience to your users without significant effort.
Usage example
<?php $form = new \Ip\Form(); $form->addField(new \Ip\Form\Field\File( array( 'name' => 'file', 'label' => 'Browse', 'fileLimit' => 5 //optional. Unlimited by default. Available since 4.2.6 ) )); echo $form->render();
In controller (where the form with such field is submitted) you will get a two dimensional array of uploaded files as POST or GET variable. This is how that variable will look like:
array ( 'file' => array ('xxx.jpg', 'yyy.jpg', ...), 'originalFileName' => array('xxx.jpg', 'yyy.jpg', ...) )
file array represents file names of uploaded files that reside in file/secure/tmp directory. Copy them to file/someCustomSubfolder or anywhere else because tmp directory is regularly cleaned up. Here is an example code to copy first file from temporary directory to your own directory for further storage:
<?php copy(ipFile('file/secure/tmp/xxx.jpg', ipFile('file/someCustomSubfolder/xxx.jpg'));
File names may be slightly different as they were on computer before uploading because of different file system, security measures, etc. Original file name can be found in originalFileName array.
You don't have to do anything regarding standard raw PHP upload approach based on $_FILE variable. It is all done for you by ImpressPages.
You can't set existing value for a File field.