y2ksw, if you're taking feature requests, here is some code I made to keep the original file names...
1) It takes only the file name, not the path-
2) It strips all non alpha-numeric characters besides underscores
3) It sets a max length and truncates any characters over the max length
4) It still appends an integer number to the end so there will never be any file name conflicts.
I added 1 new function replacing iei_getfile_index with:
PHP Code:
//Custom Code To Save Filename
function iei_get_file_index_name(&$path, &$extension, $oldfilename)
{
//Get only the file name (no directory info)
$oldfilename = basename ($oldfilename, $extension);
//Strip out non alpha-numeric characters
$oldfilename = preg_replace("#[^A-Za-z0-9_]#", "", $oldfilename );
//Set max file name length to 40 characters
$oldfilename = substr($oldfilename, 0, 40);
//Increment number if file exists
for($i = 1;; $i++)
{
$filename = "$path/$oldfilename-$i.$extension";
if(!file_exists($filename))
{
return $filename;
}
}
}
And then the call to the function under the
//Get File Index comment I changed it to:
PHP Code:
$filename = iei_get_file_index_name($path, $extension, $value);
And it's working great... brings in the files with their own (clean) names... In the off chance the file has the same name as another one, it increments the counter by 1 so they always save with a unique name.
Feel free to use some, all, or none of this as you see fit. :up: