The image uploader does not handle image name conflict resolution. This means if a user uploads an image with yui_editor, they cannot upload a second with the same name, no one else could either for that matter.

The best solution would be to integrate this with the drupal file handling functions. Then you could solve the problem of file deletion too from the file attachments properties already on this page.

The worst part of this is that the user has no error message telling them that they need to change the file name because it has already been taken. Huge usability issue there.

CommentFileSizeAuthor
#2 yui_editor-5-x-duplicateFileNames.patch744 bytesmiche

Comments

muhleder’s picture

I was having issues with this in the 5 version, so I altered the code in the module, sorry don't have a patch for it, but have made quite a few changes to the module to get it to behave. This is the code I'm using to force unique filenames in the yui_editor_image_upload() function.

Also a fix to make sure the directory exists as well.

<?php

//Check to see if directory exists and is writeable, if not then make it so.
file_check_directory($path, 1);
		
$file = file_save_upload('upload', $path, FILE_EXISTS_RENAME);
if (!$file) {
  $response->status = 'Error Reading Uploaded File.';
  print drupal_to_js($response);
  exit;
}

?>
miche’s picture

Version: 6.x-2.x-dev » 5.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new744 bytes

Based on the code from muhleder above, I created a patch for 5.x. It renames images with a _0, etc. Nice job!