This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
When we upload image with the same name it overwrite the existing image.
But actually all the image should have uniqueness (e.g Timestamps).
Thanks
Hi there,
I noticed your problem and couldn't find any setting where this is managed.
You can apply the following temporary solution until the October guys change the default behaviour:
- Open file \modules\cms\widgets\MediaManager.php
- Find the line where the filename is being set on upload:
$fileName = File::name($fileName).'.'.$extension;
- Change the line to
$fileName = File::name($fileName).date('YmdHi').'.'.$extension;
to include the year,hour and minutes after the name.
That's it. You can upload images with the same name(with 1 minute delay of course :) ).
Side note: This will always add the timestamp to the filename, no matter if the name exists or not. So this can be extended further to check if the name is present in the DB and if yes, then the timestamp to be added.
Last updated
@xchattercho3568 Thanks its working fine. If don't need delay please use below code : $fileName = File::name($fileName).date('YmdHis').'.'.$extension;
Thank you for your help.
As update, this is the new file path:
modules\backend\widgets\MediaManager.php
To replace this line:
$fileName = File::name($fileName).'.'.$extension;
with this:
$fileName = File::name($fileName)."_".date('YmdHis').'.'.$extension;
Last updated
1-4 of 4