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.

Data Model Questions /

Setting an upload to folder


Go to End
Reply


9 Posts   2687 Views

Avatar
kevino

Community Member, 30 Posts

20 November 2009 at 11:51pm

Edited: 20/11/2009 11:52pm

Can I specify where files are uploaded to?

If I'm using a normal FileIFrameField or ImageField, can I specify a setting in my *Page.php where the file will be uploaded to "assets/Uploads/*page-name*" instead of just dumping everything in "assets/Uploads"?

Would really help in terms of file organisation, and would allow me to turn off the Files and Images tab.

Avatar
baba-papa

Community Member, 279 Posts

24 November 2009 at 10:34am

Edited: 24/11/2009 10:35am

The folder is the 6th parameter of the FileField.php constructor. FileIFrameField is a direct descent of FileField.

Avatar
kevino

Community Member, 30 Posts

24 November 2009 at 10:54am

Hm, I actually really don't know how to use what you're suggesting

could I do something like this:

new FileIFrameField( 'File1', 'Upload One', '','','','assets/Uploads/$title' ),

Avatar
baba-papa

Community Member, 279 Posts

24 November 2009 at 8:25pm

Thats exactly what I was talking about.

Avatar
kevino

Community Member, 30 Posts

24 November 2009 at 10:43pm

Cool. Many thanks :)

my code peice was just a guess to be honest; will the "$title" work in this part of the code, as I've only ever used it in the ss templates.

Cheers
Kevin

Avatar
kevino

Community Member, 30 Posts

25 November 2009 at 2:12am

hm. I get an unexpexted ',' error when I try this.

I've been trying to get an upload to specify to 'assets/Uploads/$URLsegment' - if that's feasible.

Avatar
kevino

Community Member, 30 Posts

3 December 2009 at 6:07am

I still can't get this to work.

From what I can gather, the logical thing to do is this:

$fields->addFieldToTab('Root.Content.Image', new ImageField('Image', 'Image', null, null, null, 'assets/News/$URLsegment'));

works in my head, just not in practice..

Anyone?

Avatar
zenmonkey

Community Member, 532 Posts

5 December 2009 at 10:06am

I don't know if just specifying a path will actually create the directory or if it will give it the right permissions.

Go to Top