files. Getting multiple files   [3.2.2]

$form:files

Such a construction return hash with all form files. Hash keys' names are the same as the names of form fields. See below.

$form:files.field_name   

If a form field has at least one file-value, such a construction returns a hash (object of class
hash) with keys 0, 1, 2..., containing all files with specified field name. It is used for getting multiple files with the same field name.

Important notice: before performing operations with a hash, you should first check if it is defined.

Example
^if($form:files.picture){
   
<p>Loaded pics (^form:files.picture._count[]
):
   ^form:files.picture.foreach[sNum;fValue]{
      $fValue.name
      ^fValue.save[binary;/upload/pictures/${sNum}.^file:justext[$fValue.name]]
   }[,]
   </p>
}

<form method="
post" enctype="multipart/form-data">
   <p>Choose some pictures for uploading
:<br />
   <input type="file" name="picture"
 /><br />
   <input type="file" name="picture"
 /><br />
   <input type="file" name="picture"
 /><br />
   <input type=
"submit" value="Upload" />
   </p>
</form>



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 21.05.2011