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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

Cannot set custom folder for ImageField

Go to End



Community Member, 9 Posts

17 July 2009 at 12:30pm

I have created an Image Field in a HasManyComplexTable popup using the following code:

new ImageField('Photo', null, null, null, null, "PictureGallery")

I have attached an image that helps show what the form looks like.

The problem is that the images uploaded always get saved to 'Uploads' and not the folder I have specified. I inserted a Debug::backtrace() command into the Upload->load(..) method and got the following output from the CMS:

    * Upload->load(Array,)
      Line 152 of Upload.php
    * Upload->loadIntoFile(Array,Object id #57)
      Line 226 of File.php
    * File->loadUploaded(Array)
      Line 123 of Image.php
    * Image->loadUploaded(Array)
      Line 748 of Image.php
    * Image_Uploader->save(Array,Object id #33,Object id #8)
      Line 241 of Form.php
    * Form->httpSubmission(Object id #8)
      Line 129 of RequestHandler.php
    * RequestHandler->handleRequest(Object id #8)
      Line 143 of RequestHandler.php
    * RequestHandler->handleRequest(Object id #8)
      Line 122 of Controller.php
    * Controller->handleRequest(Object id #8)
      Line 277 of Director.php
    * Director::handleRequest(Object id #8,Session)
      Line 121 of Director.php
    * Director::direct(/images/index/PictureGalleryItem/8/Photo/EditImageForm)
      Line 118 of main.php

As you can see on the first line, the folder path I specified is not being passed into the method. When I look in File.php at the File->loadUploaded(..) method it says that it is deprecated, which seems like it could be the problem.

Unfortunately, I don't know enough about SS internals to figure out any more from this. Perhaps someone with more expertise could shed some light on this?

Any help with getting this working correctly would be much appreciated - I'd rather not have all my images being sent to the Uploads folder.

Attached Files