Jump to:

23471 Posts in 18937 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Specify Upload Directory (Image and File)

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

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

Page: 1
Go to End
Author Topic: 1606 Views
  • Ryoken
    Avatar
    Community Member
    18 Posts

    Specify Upload Directory (Image and File) Link to this post

    So I'm trying to upload images and files to specific directories ( It's a large site, just having everything into the uploads directory would be a mess in no time, and you can't be expected to upload files first then link after ), and I've having no luck..

    http://pastie.org/928363

    That's my code. It's my understanding that there's a problem on the most basic level. I even tried the 2.4RC version of Upload.php with no luck.

    Does anyone have a fix ? Either a custom class or fix for the current one ?

    I remember trying to do the same thing with swfupload a while back and had no luck with that either, though I haven't tried this time as they are only images, but if it works now does anyone have a functional example of that ?

    Thanks

  • Gelert
    Avatar
    Community Member
    8 Posts

    Re: Specify Upload Directory (Image and File) Link to this post

    The correct code to fix this problem is:

    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePagePhoto', 'Home Page Image (upload 600px width image, it will be resized properly)',NULL,NULL,NULL,'HomePagePhotos'), 'Content');

    Where 'HomePagePhotos' is a directory inside assets. The path is relative to assets.

    1606 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.