First off, hello everyone.
I have been using SilverStripe for about a month or two now and have been loving it, and after trawling through the docs and forum I have learned quite a bit and built a bunch of modules (heh coming soon to this site).
But now I have hit a wall.
I am trying to use a SWFUploadField on a front end page but cant get it to work and I need some help!
Here is my code
/profiles/code/ProfilePage.php
function editGallery(){
$member = Member::currentUser();
$res = "<br /><strong>Usage:</strong><br />
<ul><li>Images must be web jpgs</li>
<li>Max width: 600 pixels</li>
<li>Max height: 700 pixels</li>
<li>Uploaded files larger than the restrictions will be resized accordingly</li>
</ul>";
$folderDir = "assets/$member->ProfileURL/";
$fields = new FieldSet(
new LiteralField("fileUpload",$res),
new SWFUploadField("editGallery","Image","Upload files",
array (
'file_types_list' => '*.jpg',
'file_queue_limit' => '15',
'browse_button_text' => 'Choose images...',
'upload_url' => $this->Link('handleswfupload'),
'required' => 'true',
'button_image_url' => '/swfupload/images/upload_button_new.png'
)
)
);
$actions = new FieldSet(new FormAction("uploadGallery", "Submit"));
$validator = new RequiredFields("Image");
return new Form($this,'editGallery', $fields, $actions, $validator);
$Form->setTemplate('ProfilePage_gallery');
}
// form helpers
function handleswfupload(){
$member = Member::currentUser();
$folderDir = "Users/$member->ProfileURL/";
if(isset($_FILES["swfupload_file"]) && is_uploaded_file($_FILES["swfupload_file"]["tmp_name"])) {
$file = new File();
$u = new Upload();
$u->loadIntoFile($_FILES['swfupload_file'], $file, $folderDir);
$file->write();
echo $file->ID;
}
else{echo ' ';}
Where am I going wrong?