Question
Hi. Several of my users have asked for a 'fast attach' functionality. This would be a separate action link on the bottom bar, which would immediately bring up a file browser. Selecting a file and clicking OK, would immediately attach the file to the page, with default settings and no comment. Is there already a plan for anything like this, or is it appropriate to raise a feature request? If neither, any suggestions how I could implement this and share it back?
Environment
--
SteveJonesST - 30 Jun 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
While creating a link that pops up the browse dialog is pretty trivial, I suspect after that you 'll need a line or 2 of javascript to auto-trigger the submit on the form.
and here's a quickhack - hiding the textbox and changing the button are css styling issues - it should really be implemented as a tmpl file, that can be used to replace the 'Attach' action.
<div class="patternAttachForm">
<form name="main" enctype="multipart/form-data" action="%SCRIPTURL{upload}%/%BASEWEB%/%BASETOPIC%" method="post">
<input type="hidden" name="filename" value="" />
<input type="file" class="twikiInputField" name="filepath" value="" size="70" onChange="this.form.submit()"/>
<input type="hidden" class="twikiInputField" name="filecomment" value="" size="70" />
<input type="hidden" class="twikiCheckbox" id="createlink" name="createlink" />
<input type="hidden" class="twikiCheckbox" id="hidefile" name="hidefile" />
</form>
</div><!-- /patternAttachForm-->
even tested it

- whatever you do, don't upload something by mistake.
NOTE: this example does not degrade nicely - if the browser has javascript off, you get a totally nonfunctional browse, with no submit.
Also, the 'right' way to do this sort of thing would be an small popup giving the user the opportunity to reconsider their choice, and to optionally fill in the details.
--
SvenDowideit - 03 Jul 2008