ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker File Upload with Standard File-Field doesn't work?

December 20, 2011 8:38pm

Subscribe [5]
  • #1 / Dec 20, 2011 8:38pm

    F. Albrecht

    75 posts

    Hi,

    it seems to be that the Safecracker Form with a standard File Field for Uploads doesn’t work? I got the Safecracker Field working but I’m wondering why the standard File Field doesn’t work.

    This is my code:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>File-Upload</title>
      <meta charset="utf-8">
      <link href="{path=css/_ee_saef_css}" type="text/css" rel="stylesheet" media="screen">
    </head>
    
    <body>
      {exp:safecracker channel='pages' entry_id='1' return='site_index' include_jquery='yes'}
      
        {custom_fields}
          {if file}
            {display_field}
          {/if}  
        {/custom_fields}      
        
        <input type="submit" value="Save changes">
        
      {/exp:safecracker}
    </body>
    </html>

    Fieldtype in weblog “pages” is File (not Safecracker File).

    The page shows me the Add File Button: If I hit this link, the File Manager Modal opens and I see my image list. If I choose an image and click the link for this image in the modal the image is inserted by Javascript in my page (the word “undefined” is under the image -> filename isn’t set).

    Firebug shows an error after this action:

    $.ee_filebrowser.reset is not a function
    $(document).ready(function(){function ...browser.reset()}$(”.js_show”).show();

    After submitting the form the image isn’t saved.

    If I add an image via the Control Panel everything is working correct. When I’m trying to remove this image via Safecracker this isn’t working too.

    Thank you for your help.

  • #2 / Dec 21, 2011 9:54am

    Rob Allen

    3105 posts

    Try changing the fieldtype to Safecracker file, it’ll still work in the Control panel entry page.

  • #3 / Dec 21, 2011 4:50pm

    Kevin Smith

    4784 posts

    Yep, Rob’s hit the nail on the head for this one. If you’re using SafeCracker, it’s best to use SafeCracker File instead of the regular File fieldtype.

    If you use this instead, does it solve the problem?

  • #4 / Dec 21, 2011 5:01pm

    F. Albrecht

    75 posts

    Yes, Safecrackerfile works - I mentioned this in my 1st post. But this isn’t the problem: I’m wondering how to use the File Manager Modal Window - the Safecracker File offers only a very reduced image selection dialog.

    In File Manager Modal I have thumbnails etc.. How can I make the FM working in the frontend?

  • #5 / Dec 23, 2011 2:35pm

    Dan Decker

    7338 posts

    F. Albrecht,

    I’m afraid the standard file field isn’t intended to be used with SafeCracker, which is why there is a specific field type for SafeCracker. If you would like to see the standard file field for use with SafeCracker, please feel free to make a Feature Request. You may also want to use Pixel & Tonic’s Assets, it works well with SaceCracker.

  • #6 / Aug 30, 2012 1:01pm

    Susan

    81 posts

    This thread has been very helpful for me. Explained what to do, and confirmed to me that my options are less robust now that I’ve done it.

    I will summarize my findings (since oftentimes the results are gathered reading in several posts) in this step-by-step:

    Creating a SAEF for a channel entry that includes uploading files? Here’s what you gotta change:

    Add-ons > Modules: Install Safecracker.

    Add-ons > Fieldtypes: SafeCracker File: Install.

    Admin > Channel Administration > Channel Fields: Edit whatever field group has the File field type in it. Change from File to SafeCracker File.

    In the template that uses Safecracker,

    change this

    {if file}
         {display_field}
    {/if}

    to this:

    {if safecracker_file}
         {display_field}
    {/if}

    I guess I’ll go add my vote to to the Feature Requests and check out Assets

  • #7 / Aug 31, 2012 9:57am

    Kyle Cotter

    730 posts

    Glad to see Safecracker file does the trick for you.

    And we totally want you to go add your vote to the Feature Request forum 😉

    If you have any more questions, feel free to start a new thread.

    Thanks!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases