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.

  1. 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.

  2. 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 the exp_weblog_fields table
  3. Add the following code to your SAEF (below the {/custom_fields} tag), exchanging 9 for your unique Field_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"/>
  4. 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:

3 Comments

  1. @Jonathan – I had some troubles at first too, but with the help of this thread I got it working. The extension needs to be massaged a bit, but it’s better then messing with the core files.

    Thanks Jonathan for the post!

Leave a Comment.