The release notes for Assets 2 says "Added support for simple HTML file field uploads via SafeCracker".

Does anyone have any example template code of how this should work, including how to remove the file if necessary? I can't see anything in the docs.

1 Answer 1


If you have an Assets field called “article_images”, you can create a simple HTML upload input like so:

<input type="file" name="article_images">
<input type="hidden" name="article_images_filedir" value="1">

The first input is the actual File input, and the second tells Assets which upload directory to place it in.

In time, Assets will also support the multiple="multiple" attribute on the File input, for uploading multiple files at once, but for that we need a small SafeCracker patch to make it to an official EE release.

  • Great. Is there a way to remove the file once it's uploaded or can it only be replaced? Mar 18, 2013 at 21:34
  • 1
    Jamie, no, not at the moment. Mar 19, 2013 at 12:42
  • There's a bug with Assets 2.1 with that image manipulations do not work for images uploaded via simple HTML file fields.
    – Michael P
    Apr 18, 2013 at 7:10
  • 1
    After a couple of months trying, I finally got this working ;) <input type="hidden" name="article_images" value="NULL" /> <input type="file" name="article_images" /> <input type="hidden" name="article_images_filedir" value="1" /> I borrowed that first hidden field code from Safecracker and it now works. I'm not sure if it's down to something EL changed recently. May 16, 2013 at 17:11
  • 30 months late, but here's the proper way to implement this: expressionengine.stackexchange.com/a/32896/55 Sep 2, 2015 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.