问题描述:

I'm using the following module for uploading multiple images:

https://github.com/bummzack/sortablefile

I use the has-many relationship.

class PortfolioPage extends Page

{

private static $has_many = array(

'Images' => 'PortfolioImage'

);

class PortfolioImage extends Image

{

private static $has_one = array(

'PortfolioPage' => 'PortfolioPage'

);

}

The problem is that when uploading multiple images with the same file name it gives me the following error: File with the same name already exists .

How can I avoid this such that it will be possible to upload multiple images when they have the same filename?

Thank you

网友答案:

Actually this error is "natural" behavior, it's impossible to store multiple files with identical names in one directory.

Please read discussion on GitHub for more information.

网友答案:

SortableUploadField is extending the UploadField, try adding setOverwriteWarning to False in your getCMSFields section. Check the code below:

$uploadField = new SortableUploadField('Images', 'Upload Images');
$uploadField->setOverwriteWarning(FALSE);
$fields->addFieldToTab("Root.Main", $uploadField);

Take note, this only prevents the error and rename the duplicate file name. Example: if you upload same file name like file.jpg, the second file.jpg will be renamed to 2.jpg, 3.jpg, etc.

相关阅读:
Top