Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » File Uploads

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 891 Views
  • Aaron
    Avatar
    Community Member
    63 Posts

    File Uploads Link to this post

    I am trying to add a tab to a page type called "Files", that will allow the user to upload a PDF (just one) that will attach to the page, so I can access it and place a link to it in a certain box in my .ss files.

    class Tour extends Page {

       static $db = array(
       );
       

       static $has_one = array(
          'PDF' => 'File'
       );

    function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab( 'Root.Content.Files', new FileIFrameField('PDF', 'Upload and Attach Dossier PDF') );
    return $fields;
    }

    1. This code displays an "Attach Image" Iframe, which is a little confusing
    2. When a file is selected (a pdf) and "attach image" button is hit, page refreshes but nothing happens. No Mime Type image (not sure if there should be) and no confirmation.
    3. File is present in Assets directory under "Uploads"
    4. There is no link to the file in the Database, and accessing it from the template gives nothing.

    Any help please. There is only two other posts on this forum, one has very similar code to what I have above, and claims that it works. The other simply wasn't answered. The docs tell me nothing.

    Cheers
    Aaron

  • Aaron
    Avatar
    Community Member
    63 Posts

    Re: File Uploads Link to this post

    Cancel that - the above code works. I had a slight spelling error on the file field name in my running code.

    891 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.