Please help somehow

EC site to create a "ubercart_marketplace" are using to upload the file.

If there are files with the same name in upload folder, the file will be overwritten without being renamed.

"mp_file.module" I think you have not worked well in the following code.

----------------
function mp_file_mp_file_name($dir, $file_name, $file_name_ext, $node_id, $title ,$new_name_hook ) {
$node_sanitized_title = preg_replace('/[^0-9a-z\.\_\-]/i', '', $title);

$new_file_name = $node_id . "_" . $file_name . "." . $file_name_ext;

// We could now return $new_file_name but first let's rename it if this file name already exists.
// NB: $file_name also has a counter in it for files in the temp directory
$i_file = 0;
while (file_exists($dir . $new_file_name)) {
$i_file++;
$new_file_name = $node_id . "_" . $file_name . "_" . sprintf('%03d', $i_file) . "." . $file_name_ext;
}

return $new_file_name;
}
----------------

If the file already existed with the same name, to rename the file? How can I.

Has created a website to sell digital content, and products will be replaced by sliding the file is overwritten. We think a very big problem.

Please tell us.
Thank you.

CommentFileSizeAuthor
#3 mp_filemodule.txt14.84 KBjirou_ueda

Comments

jirou_ueda’s picture

Assigned: jirou_ueda » Unassigned

Really in need will be overwritten.

If there is no solution, how to get a unique ID can be uploaded to the file.

Other dates are given in the file name, for example, I would appreciate a way to avoid the same file name exists.

thedavidmeister’s picture

jirou_ueda’s picture

StatusFileSize
new14.84 KB

Hello thedavidmeister
Thank you for the comment.

I tried to reference a URL I learned did not work.
PHP is about a novice, "mp_file.module" very helpful and I get what you need to change how anywhere.

We will also file attachments, please check.
Thank you.

jirou_ueda’s picture

Are really in need. Could you or anyone teaching us.

jirou_ueda’s picture

Status: Active » Closed (fixed)
jirou_ueda’s picture

Issue summary: View changes

Has created a website to sell digital content, and products will be replaced by sliding the file is overwritten. We think a very big problem