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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Unable to upload an image (SS 3.1.1)


Go to End


3 Posts   1350 Views

Avatar
LoFonz

Community Member, 12 Posts

16 October 2013 at 1:31am

Edited: 16/10/2013 1:37am

Hi everyone, I'm having some troubles uploading a simple image on a simple page.php... I did everything I need to do, and I'm 100% sure my code is correct, but I'm still having a weird error, I enclosed a .JPG on which you can see the error, it's a JQuery error, but I can't find out why I'm getting it :/

It looks like this is a Json error, but seriously, why? O_O

EDIT : I'm doing this on a fresh install of the latest update of SS..

Btw, here's the code I used to create the image, just to make sure :)

private static $has_one = array(
    'Photo' => 'Image'
);

public function getCMSFields() {
    $fields = parent::getCMSFields();
         
    $fields->addFieldToTab("Root.Main", new UploadField('Photo'));
         
    return $fields;
}

Thank you :-)

Attached Files
Avatar
LoFonz

Community Member, 12 Posts

16 October 2013 at 2:32am

Wow this is weird, when I change the "new UploadField('Photo')" to "new UploadField('whatever'), I don't get the error anymore (but of course, I can't upload a picture hum..).

It doesn't make sense at all ^^'

Avatar
LoFonz

Community Member, 12 Posts

16 October 2013 at 3:39am

And I don't get the error anymore if I empty my "silverstripe-cache" folder, but I still can't get the upload to work..