Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

File Uploads


Reply


2 Posts   970 Views

Avatar
Aaron

Community Member, 63 Posts

8 June 2008 at 10:42pm

Edited: 08/06/2008 11:21pm

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

Avatar
Aaron

Community Member, 63 Posts

8 June 2008 at 11:23pm

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