Hi, I'm new to SilverStripe and I want to upload Files such as doc, docx, pdf, txt as well as jpg, png...
what is a good way to do this?
I currently have this,
<?php
class ResourcesPage extends Page {
static $db = array(
);
static $has_one = array(
'UploadedFile' => 'File',
'UploadedImage' => 'Image'
);
public function populateDefaults(){
parent::populateDefaults();
}
public function getCMSFields() {
$fields = parent::getCMSFields();
$fileUpload = new UploadField( 'UploadedFile', 'Select PDF file' );
$imageUpload = new UploadField( 'UploadedImage', 'Select image' );
$fields->addFieldToTab( 'Root.Files', $fileUpload );
$fields->addFieldToTab( 'Root.Files', $imageUpload );
return $fields;
}
}
class ResourcesPage_Controller extends Page_Controller {
}
Is it possible to have one UploadField that can upload a File/Image?
in my template
<a href="$UploadedFile.Link" >Download Link</a>
<a href="$UploadedImage.Link" >Download Link</a>
In the front end, a link will be provided so the user can download the File/Image
not sure about the
static $has_one = array(
'UploadedFile' => 'File',
'UploadedImage' => 'Image'
);
any suggesstions? :)