ExpressionEngine: adding easy file upload to SAEF
Apologies to my readers who are less than interested with tech and code related posts. I’m plotting a way to separate my posts, so that you won’t be subjected to this much longer. Thanks for your patience!
This post continues from yesterday, since I ran into problems trying to implement the easy file upload in the SAEF (Stand Alone Entry Form). After much searching in the forums, and Google, I discovered how I could get this running smoothly. The following assumes that you have already installed Mark Huot’s File Upload Extension and have it up and running through your control panel.
- Modify your
mod.weblog_standalone.php(found at /system/modules/weblog/mod.weblog_standalone.php) so that instead of reading:
$data = array(
'hidden_fields' => $hidden_fields,
'action' => $RET,
'id' => 'entryform'
);It reads:
$data = array(
'hidden_fields' => $hidden_fields,
'action' => $RET,
'id' => 'entryform',
'enctype' => 'multipart/form-data'
);For more information read this article by Chad Crowell.
- Find out the
Field_ID,for the custom field that you are wanting to add to, in the Control Panel by going to Admin > Utilities > SQL Manager > Manage Database Tables and browsing theexp_weblog_fieldstable - Add the following code to your SAEF (below the
{/custom_fields}tag), exchanging9for your uniqueField_ID
<label for="content">File Upload:</label>
<input class="required" id="file_content" title="Please upload a file. This field is required." name="field_id_9_img[]" type="file" class='file' />
<input type="hidden" value="" class="file" name="field_id_9"/>
<input type="hidden" value="file" class="file" name="field_ft_9"/> - And, finally, test to see if it works properly before going live with a client’s site.
For more on this, please take a look at the following links from the EE forum:
- How to get Mark Huot’s File Extension to work with SAEF/Stand Alone Entry Form
- An extension that can be used instead of hacking the
mod.weblog_standalone.phpfile.
- Mark Huot’s actual Extension