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

setField('Filename... ignored in Upload.php


Go to End


3 Posts   2100 Views

Avatar
Wilson

Community Member, 63 Posts

3 April 2010 at 6:27am

Hi all,

I'm doing something hacky (I know... ) but planning to fix it later. First I just need it working.

In Upload.php, I'm trying to set the Filename of my upload before it's written to the database. It's currently being written incorrectly. For example, if I upload the file to:

/assets/7/Photo-Gallery/myFile.jpg

It's written to the database as:

/assets/myFile.jpg

I'm attempting to add this line:

$this->file->setField('Filename', CORRECT VALUE AS A STRING);

... then write()

But it seems to be ignored or overwritten by an ancestor, perhaps DataObject??

In the API docs, it says the 2nd param can be mixed. Does this indicate that it should be an object or array instead of string?

I'm running beta1, but I've looked through trunk and it doesn't look like any of this has a bug in it.

Thanks for your advice!

Wilson

Avatar
swaiba

Forum Moderator, 1899 Posts

1 April 2011 at 10:41am

Edited: 03/04/2011 12:28am

<withdrawn rant as previous comment deleted>

Avatar
stefant42

Community Member, 14 Posts

2 April 2011 at 2:39am

I'm sorry but yesterday i was sitting the hole day on the same problems. Sorry for my comment