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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | mp_filemodule.txt | 14.84 KB | jirou_ueda |
Comments
Comment #1
jirou_ueda commentedReally 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.
Comment #2
thedavidmeister commenteddoes this help with generating unique id's?
http://phpgoogle.blogspot.com/2007/08/four-ways-to-generate-unique-id-by...
Comment #3
jirou_ueda commentedHello 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.
Comment #4
jirou_ueda commentedAre really in need. Could you or anyone teaching us.
Comment #5
jirou_ueda commentedComment #5.0
jirou_ueda commentedHas created a website to sell digital content, and products will be replaced by sliding the file is overwritten. We think a very big problem