(Added parsecontent example with template) |
|||
Line 14: | Line 14: | ||
'''pagecontent ''': Text content to be added on the File Page | '''pagecontent ''': Text content to be added on the File Page | ||
− | '''force ''': | + | '''force ''': Force images to a certain format (png, jpg or gif). When using this option, you cannot upload files other than images. |
'''error_id ''': Id of a DOM Element where error notices will be shown | '''error_id ''': Id of a DOM Element where error notices will be shown | ||
Line 24: | Line 24: | ||
'''dropzone ''': Doesn't require a value. Will turn the verbose div into an additional file drop zone | '''dropzone ''': Doesn't require a value. Will turn the verbose div into an additional file drop zone | ||
− | '''parsecontent''': Will force FlexForm to | + | '''parsecontent''': Will force FlexForm to insert values from other form fields inside the pagecontent field. Use square brackets, like [fieldname], where values should be inserted. |
'''*'''= a required variable | '''*'''= a required variable | ||
Line 34: | Line 34: | ||
===Example=== | ===Example=== | ||
This example accepts only a value between 0 and 10 with steps of 0.01 (e.g. 2.21) | This example accepts only a value between 0 and 10 with steps of 0.01 (e.g. 2.21) | ||
− | Example 1 | + | |
+ | ==== Example 1 ==== | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<_input type="file" target="pictures-[filename]-[mwrandom]" pagecontent="Information of the test file" error_id="div-error" verbose_id="div-verbose" /> | <_input type="file" target="pictures-[filename]-[mwrandom]" pagecontent="Information of the test file" error_id="div-error" verbose_id="div-verbose" /> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Example 2 | + | ==== Example 2 ==== |
− | |||
Always make sure an image will be transformed to jpeg. | Always make sure an image will be transformed to jpeg. | ||
Line 52: | Line 52: | ||
<_input type="submit" value="upload" /> | <_input type="submit" value="upload" /> | ||
</_form> | </_form> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== Example 3 ==== | ||
+ | Store a template to the pagecontent. You can use this if you want the filepage to have structured content or if you want to store structured data with an extension like SMW.<syntaxhighlight> | ||
+ | <_form action="addToWiki" enctype="multipart/form-data" > | ||
+ | {{#tag:_input ||type=file |id=file-upload |target=picture-[mwrandom] |parsecontent=true |pagecontent=<nowiki>{{Uploaded file | ||
+ | |Uploaded from page=</nowiki>{{FULLPAGENAME}}<nowiki> | ||
+ | |Uploaded by=</nowiki>{{CURRENTLOGGEDUSER}}<nowiki> | ||
+ | |Comment=[Comment] | ||
+ | }}</nowiki> | ||
+ | }} | ||
+ | <_input type="text" name="Comment" placeholder="Comment" /> | ||
+ | <_input type="submit" value="upload" /> | ||
+ | </_form> | ||
+ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 11:43, 23 February 2022
Name
file
Type
_input
Synopsis
Using file uploads
Description
Use a form to upload one or multiple files.
Parameters
_input type="file"
target* : Name of the File Upload Wiki Page
pagecontent : Text content to be added on the File Page
force : Force images to a certain format (png, jpg or gif). When using this option, you cannot upload files other than images.
error_id : Id of a DOM Element where error notices will be shown
verbose_id : Id of a DOM element where information about the file is shown
use_label : Doesn't require a value. When an input field has a label attached to it, then the label will become the upload button and the input field will be hidden
dropzone : Doesn't require a value. Will turn the verbose div into an additional file drop zone
parsecontent: Will force FlexForm to insert values from other form fields inside the pagecontent field. Use square brackets, like [fieldname], where values should be inserted.
*= a required variable
The target is basically the name you want to use to store the file or files. It recognizes [mwrandom], [filename] and other form fields, by using their name with square brackets around them (see example). pagecontent can also hold form variables.
Example
This example accepts only a value between 0 and 10 with steps of 0.01 (e.g. 2.21)
Example 1
<_input type="file" target="pictures-[filename]-[mwrandom]" pagecontent="Information of the test file" error_id="div-error" verbose_id="div-verbose" />
Example 2
Always make sure an image will be transformed to jpeg.
Allow for multiple file upload.
Add form text field "description" on the files page content.
<_form action="addToWiki" enctype="multipart/form-data" >
<_input type="file" multiple="multiple" parsecontent target="pictures-[filename]-[mwrandom]" pagecontent="Information for this image: [description]" force="jpg" />
<_input type="text" name="description" />
<_input type="submit" value="upload" />
</_form>
Example 3
Store a template to the pagecontent. You can use this if you want the filepage to have structured content or if you want to store structured data with an extension like SMW.
<_form action="addToWiki" enctype="multipart/form-data" >
{{#tag:_input ||type=file |id=file-upload |target=picture-[mwrandom] |parsecontent=true |pagecontent=<nowiki>{{Uploaded file
|Uploaded from page=</nowiki>{{FULLPAGENAME}}<nowiki>
|Uploaded by=</nowiki>{{CURRENTLOGGEDUSER}}<nowiki>
|Comment=[Comment]
}}</nowiki>
}}
<_input type="text" name="Comment" placeholder="Comment" />
<_input type="submit" value="upload" />
</_form>
Note
A _input type="file" always needs a unique ID!