


Summarize the method of naming attachments uploaded by Empire CMS to be named 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 of naming is very uncomfortable for users, and it is not conducive to us adjusting or replacing attachments through FTP. Therefore, sometimes we need to change the uploaded attachment to the rule named after the original file name. The specific method is as follows:
1. Open the file \e\class\connect.php
Search Go to:
The code is as follows:
$r[filetype]=GetFiletype($file_name);
Add below:
The code is as follows:
$filename2=str_replace($r[filetype], '', $file_name);//获得去掉后缀的文件名 $mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf");//定义需要保留原名的 文件类型
It is recommended to study "Empire cms tutorial 》
2. Find the code for
as follows:
$r[filename]=$r[insertfile].$r[filetype];
and modify it as:
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 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 Summarize the method of naming attachments uploaded by Empire CMS to be named with the original file name. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version
God-level code editing software (SublimeText3)