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.

Blog Module

Discuss the Blog Module.

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

Using Uploadify on the Front End Blog Entry Form


8 Posts   1522 Views


23 July 2011 at 3:48am Community Member, 108 Posts


I recently tried adding this snippet of code:
new FileUploadField('AttachedImage', 'Upload an image', array (
'buttonText' => 'Upload an Image')),

to BlogHolder.php

This creates the upload button on the front end blog entry form but it doesn't seem to function properly. It lets me select an image but does not actually upload an image. Instead it says no file attached.

Any suggestions would be great.



23 July 2011 at 4:16am (Last edited: 23 July 2011 4:43am), Community Member, 4 Posts

First you must create a decorator for the blog entries.

1. Create a file in mysite/code called: BlogEntryDecorator.php and paste the following code:

class BlogEntryDecorator extends SiteTreeDecorator {
function extraStatics() {
return array(
'has_one' => array(

function updateCMSFields(& $fields){
$fields->addFieldToTab('Root.Content.Image', new ImageField('AttachedImage','Attach an image to this blog entry'));

2. Add the following line to your _config.php:

DataObject::add_extension('BlogEntry', 'BlogEntryDecorator');

3. Add your code to BlogHolder.php file (after the line 231 and before line 240):

new FileUploadField('AttachedImage', 'Upload an image', array ( 'buttonText' => 'Upload an Image')),

you can use ImageUploadField instead of FileUploadField (since we want to upload only images):

new ImageUploadField('AttachedImage', 'Upload an image', array ( 'buttonText' => 'Upload an Image')),

4. Add the following code to your templates (,, etc.)

<% if AttachedImage %>
<% end_if %>

5. Before you try, visit

And you're done!


23 July 2011 at 7:02am Community Member, 108 Posts

Thanks @nekrasov ! But i just tried all of these steps and my upload button on the front end still doesn't work. For a split second I see what looks like a loading bar, but then is disappears and nothing is attached. I did the database flush prior to testing this.

Any idea where things might be going wrong?



23 July 2011 at 8:23am Community Member, 4 Posts

To help you better, I need to know:

1. Which version of Silverstripe you are running?

2. What is your development environment ? (XAMP, MAMP, WAMP, PHP version)

3. Versions of Blog Module and Uplodify

4. Check the memory allocation in php.ini
search for: max_execution_time, max_input_time, memory_limit, post_max_size, upload_max_filesize
and try to increase their values.

I remember that in a recent version of Silverstripe there were problems with the extensions JPG or JPEG (uppercase) when you were trying to upload an image.

With the release of Silverstripe 2.4.5: Bugfix: Valid file uploads with uppercase extensions blocked from being web accessible

Check the changelogs: [url][/url]

I hope you find this information helpful.


24 July 2011 at 5:31am Community Member, 108 Posts

Thanks nekrasov!!

My answers:

1. SS 2.4.5
2. MAMP, PHP 5.3.5
3. Blog Module 0.4.1, Uploadify - The most recent? I downloaded it this week
4. This is what I currently have for those items:
max_execution_time   30   
max_file_uploads   20   
max_input_nesting_level   64   
max_input_time   60   
memory_limit   32M
post_max_size   32M
upload_max_filesize   32M

The file I was trying to upload had a lowercase .jpg

I haven't tried increasing any of the PHP values yet. I'll let you know if that helps.



26 July 2011 at 3:46am Community Member, 108 Posts

Just to give an update I increased the memory limit to 64M and still no luck. Plus the image that I tried is pretty small. I also tried a different test image and got the same result.

Any additional suggestions would great, thanks!


27 July 2011 at 4:22am Community Member, 4 Posts

Hello juneallison!

OK, I don't know why you can't upload the image with uplodify.

But there is another option to achieve this:

Use the class SimpleImageField
Summary: SimpleImageField provides an easy way of uploading images to Image has_one relationships.

Just change the line that you added to BlogHolder.php:

new FileUploadField('AttachedImage', 'Upload an image', array ( 'buttonText' => 'Upload an Image')),

with the following:

new SimpleImageField('AttachedImage', 'Upload an image'),

That's all!

I really hope all of this works for you!


27 July 2011 at 4:47am Community Member, 108 Posts

Thank you!!! This works and is all that I needed.

I really appreciate your help!