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

Overwrite files when uploading new files with the same name


Go to End


3 Posts   1569 Views

Avatar
jkdude

Community Member, 19 Posts

21 April 2015 at 11:39am

Hi. One of our client's CMS has been set up so that when a file with a duplicate filename is uploaded, an incremented number is appended to the end of the filename and it uploads it automatically without the overwrite option.

They've asked us to revert it back to having the overwrite option pop up again. Anyone know how it was done in the first place so I can reverse the process.

Cheers,
JK

Avatar
Devlin

Community Member, 344 Posts

22 April 2015 at 2:20am

# replace files instead of versioning
Upload:
  replaceFile: true
# show an overwrite warning
UploadField:
  defaultConfig:
    overwriteWarning: true

... or per instance ...

$uf = new UploadField();
$uf->upload->setReplaceFile(true);
$uf->setOverwriteWarning(true);

Maybe it would be prudent for you to set up some permssions for your files because clients sometimes don't know if a particular file is safe to be replaced.

Avatar
jkdude

Community Member, 19 Posts

23 April 2015 at 2:43pm

Great. Thanks for that.