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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Image Gallery Custom Form


Go to End


2 Posts   2179 Views

Avatar
Lydia

Community Member, 6 Posts

24 June 2009 at 11:04am

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/');

}

Avatar
Lydia

Community Member, 6 Posts

24 June 2009 at 11:23am

THIS IS THE ALERT ERROR I GET WHEN I SEND THE IMAGES WITH THE FOLLOWING CODE:

CAN ANYONE HELP ME DEBUG THIS???

[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://cleanupweek.toast.co.nz/swfupload/javascript/fileprogress.js?m=1245792615 :: FileProgress :: line 42" data: no]