Jonathan Morgan Design, Justice, Jesus, Music, Life

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

Very cool… but I really, really hate making modifications to core EE files… it makes the upgrade process tricky!

Posted by Ian Pitts on 27 February 2009 @ 3pm

I know what you mean. There is an extension you can use to do the same thing(and discussion of how to get it working here), but I struggled to get it working, so went with this option.

Posted by Jonathan on 27 February 2009 @ 4pm

@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!

Posted by Nate on 1 March 2009 @ 7am

Leave a Comment

ExpressionEngine: File Upload extension Fairtrade Dairy Milk?