7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Cant get SWFUploadField to work on front end
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1411 Views |
-
Cant get SWFUploadField to work on front end

12 July 2009 at 11:40pm
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?
-
Re: Cant get SWFUploadField to work on front end

14 July 2009 at 1:08am
I need more to go on than "it doesn't work." What is it not doing? Are there any errors?
-
Re: Cant get SWFUploadField to work on front end

15 July 2009 at 12:35pm
Well basically I press the submit button for my form and then the page goes through the SS form processing and the if statement -
returns false and nothing goes through- no error messages are reported in dev mode or anything.if(isset($_FILES["swfupload_file"]) && is_uploaded_file($_FILES["swfupload_file"]["tmp_name"]))
I can use regular form fields and such and they upload files fine but when I use this one I have no indication of what went wrong.
Is there no obvious reason why the field isnt uploading things?
-
Re: Cant get SWFUploadField to work on front end

15 July 2009 at 1:47pm
Out of curiosity, how did you confirm that that if block is failing? Are you using the SWFUpload debug mode?
-
Re: Cant get SWFUploadField to work on front end

15 July 2009 at 7:12pm
The problem was with my code, and the SWF debug helped me find that (wish I saw it earlier).
The error was with something I am building into my pages, a tinyURL type system. Problem was that I had an array of things to ignore as part of that system, and I had "handleswfupload" ignored but not "handleswfupload#". Whoopsy.
Also noticed that there was r212 out and I was using r197 (from extensions/module link).
Thanks for your help.
| 1411 Views | ||
|
Page:
1
|
Go to Top |

