Hi,
Im working on a site where people can register their own clean-up event and it gets listed on the site - another feature is uploading images to the image gallery - I have the image gallery installed and its working fine on the CMS side - there are three different albums at the moment - what I'm looking to create now is a Custom Image upload form on the FrontEnd where those who have participated in a clean-up event or hosted a clean-up event can upload their photos to one of the galleries - I could just create a simple image field upload however I'd like to use swfUpload feature - currently Ive just tried editing the example given for sending a document with in an email however I know this won't work as the submit function needs editing - Ive got the form displaying fine and swfUpload will attach file just the submit section needs work!! Clearly I'm far from being a master coder - Could someone point me in the right direction?? It would be greatly appreciated!!
THIS IS WHAT I'm working with:
public function CleanUpImageForm(){
SWFUploadConfig::addFileTypes(array(
'jpg','tiff'
));
return new Form(
$this,
"CleanUpImageForm",
new FieldSet(
new TextField('Name'),
new SWFUploadField(
"CleanUpImageForm",
"CleanUpPic",
"Upload your images",
array (
'file_upload_limit' => '2',
'required' => 'true'
)
)
),
new FieldSet(
new FormAction('doImageSubmit','Apply now')
)
);
}
public function handleswfupload(){
if(isset($_FILES['swfupload_file']) && is_array($_FILES['swfupload_file']))
echo Folder::findOrMake('CleanUpPics')->addUploadToFolder($_FILES['swfupload_file']);
else echo ' ';
}
public function doImageSubmit($data,$form)
{
$upload = new File();
if(isset($_POST['uploaded_files']) && is_array($_POST['uploaded_files'])) {
foreach($_POST['uploaded_files'] as $id) {
$file = DataObject::get_by_id("File",$id);
}
$upload->write();
Director::redirect('gallery/');
}