How does Empire CMS name the attachment with the original file name?
When Empire CMS uploads the last attachment through the editor's upload attachment function, the original program will rename the attachment, and the naming results will be named with a long string of alphanumeric combinations. This form The naming method is very uncomfortable for users and is not conducive to us adjusting or replacing attachments through FTP.
Therefore, sometimes we need to change the uploaded attachment to the rule of naming it with the original file name. The specific method is as follows:
Recommended: "Empire cms website building tutorial 》
1. Open the file \e\class\connect.php
Find:
The code is as follows:
$r[filetype]=GetFiletype($file_name);
Add it below :
The code is as follows:
$filename2=str_replace($r[filetype], '', $file_name);//获得去掉后缀的文件名 $mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf");//定义需要保留原名的文件类型
2. Find
The code is as follows:
$r[filename]=$r[insertfile].$r[filetype];
Change to:
The code is as follows:
if(in_array($r[filetype],$mytype)){ $r[filename]=$filename2."_".$r[insertfile].$r[filetype];//将真实文件名加在随机码的前面中间以_分隔 } else { $r[filename]=$r[insertfile].$r[filetype]; }
The modification is now completed!
Additional explanation:
The code is as follows:
$mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf");
This sentence defines which file types need to be added with the source file name.
.$r[insertfile] This represents the random code
.$r[filetype] This represents the file type
$filename2 This represents the original file name
The above is the detailed content of How does Imperial CMS name attachments with original file names?. For more information, please follow other related articles on the PHP Chinese website!