Assuming in a HTML form, you have two file-upload fields, one for image and one for music, and the web action is insert:
<input type=hidden name="action" value="insert" /> <input type=file name="field1" /> <input type=file name="field2" />
To use the uploading feature in Genelet, you should define an upload hash in this format in corresponding action’s ACTION_hash:
upload => { html_field => {filename, directory, renamed}, html_field => {filename, directory, renamed}, ... }
If renamed is not defined, the variable filename (of the uploaded file) will be determined by the server. If it is specified, the file will always be renamed to the given name.
In the above example, you should add upload to insert:
__PACKAGE__->setup_accessors( actions => { topics => {...}, upload => {...}, insert => { upload => { field1 => ["filename_image", "/home/www/ht_docs/images"], field2 => ["filename_music", "/home/www/ht_docs/music", "kids.mp4"] }, groups => [...], musts => [...] }, edit => {...}, 'delete' => {...} }, fks => {...} );
In the upload map, key is the HTML input name; value is a 3-element array reference.
After the form is submitted to Genelet, you will receive two incoming variables filename_image and filename_music. Their values are uploaded files’ names, somehow arbitrarily assigned by the server. The image file will be located in directory /home/www/ht_docs/images, the music file in directory /home/www/ht_docs/music. You may manually choose their name as the third argument, like kids.mp4.