Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Widgets
SilverStripe Forums » Widgets » Help for upload image using widget
Discuss SilverStripe Widgets.
|
Page:
1
|
Go to End | |
| Author | Topic: Help for upload image using widget | 292 Views |
-
Help for upload image using widget

6 June 2009 at 7:35pm
Hi experts,,
I wrote code for upload image using silverstripe widget...
Using the below code to upload the image,, it does not showed in admin side..
What is the error please advice me
class FeaturedProductWidget extends Widget {
static $db = array(
"Name" => "Varchar(255)", //location of folder to upload files to
"Description" => "Text", //landing page after user uploads image
"ImageName" => "Varchar(255)"
);static $title = "Feature Product Upload";
static $cmsTitle = "Feature Product Upload";
static $description = "Display an Feature Product for upload.";function getCMSFields() {
return new FieldSet(
new TextField("Name", "Name of the product."),
new Text("Description", "Description of the product."),
new HiddenField("ImageName", "Name of the product.")
);
}function Form() {
$controller = new FeaturedProductWidget_Controller($this);
return $controller->Form();
}}
class FeaturedProductWidget_Controller extends Controller {
protected $widget;function __construct($widget = null) {
if($widget) $this->widget = $widget;
}function widget() {
if($this->widget) return $this->widget;
else if(is_numeric($this->urlParams['ID'])) return $this->widget = DataObject::get_by_id('Widget', $this->urlParams['ID']);
else user_error('No widget selected', E_USER_ERROR);
}function Link() {
if($this->widget()) return $this->class . '/' . $this->widget()->ID;
else return $this->class . '/';
}
function Form() {
return new Form($this, "Form", new FieldSet(
new SimpleImageField (
$name = "FileTypeID",
$title = "Upload your image"
)
), new FieldSet(
// List the action buttons here - doform executes the function 'doform' below
new FormAction("doForm", "Submit")// List the required fields here
), new RequiredFields(
"FileTypeID"
));
}function doForm($data, $form) {
$file = new File();
$file->loadUploaded($_FILES['FileTypeID']);// Redirect to a page thanking people for registering
// Director::redirect($this->Redirect);
}
}thanks
| 292 Views | ||
|
Page:
1
|
Go to Top |
Currently Online: Euphemismus, Allisone
Welcome to our latest member: Eco

