This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

detrojaashish
detrojaashish

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

xchattercho3568
xchattercho3568

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:

  1. Open file \modules\cms\widgets\MediaManager.php
  2. Find the line where the filename is being set on upload: $fileName = File::name($fileName).'.'.$extension;
  3. 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

detrojaashish
detrojaashish

@xchattercho3568 Thanks its working fine. If don't need delay please use below code : $fileName = File::name($fileName).date('YmdHis').'.'.$extension;

behiry
behiry

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.