Fri Sep 12, 2008
Textpattern mem_form Plugin v0.5
It is now possible to include file uploads with mem_form, Textpattern generic HTTP Form Plugin, with the most recent version. The file upload will get uploaded to a temporary file on the first submit and the tmp_name, type and name from $_FILES will be stored for use by a “form.submit” handler. If there are data errors with other form fields, the file input field can be configured to show details of the previously uploaded file or the file upload field so the user can select a different file to submit with the form.
Plugin Example
register_callback('mem_file_form_submitted', 'mem_form.submit');
function mem_file_form_submitted()
{
global $mem_form_values;
dmp($mem_form_values);
foreach($mem_form_values as $k=>$v)
{
// find the uploaded temp file and delete it
if (is_array($v) && isset($v['tmp_name']) && file_exists($v['tmp_name']))
unlink($v['tmp_name']);
}
}
function mem_file_form($atts,$thing='')
{
return mem_form(array('type'=>'file-form', 'enctype'=>'multipart/form-data'),$thing);
}
Template Tag Example
<txp:mem_file_form type="file-form">
<txp:mem_form_text name="file_title" label="Title" required="1" /><br />
<txp:mem_form_file name="myfile" label="File" /><br />
<txp:mem_form_submit />
</txp:mem_form>
file:
mem_form.txt [109.66KB]
Category: Textpattern
download: 3337
file:
mem_form.gz.txt [21.15KB]
Category: Textpattern
download: 1412
Comment
Commenting is closed for this article.





