Home > CMS Tutorial > Empire CMS > body text

Summarize the method of naming attachments uploaded by Empire CMS to be named with the original file name

silencement
Release: 2019-11-29 14:22:10
forward
2713 people have browsed it

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);
Copy after login

Add below:

The code is as follows:

$filename2=str_replace($r[filetype], '', $file_name);//获得去掉后缀的文件名
$mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf");//定义需要保留原名的
文件类型
Copy after login

It is recommended to study "Empire cms tutorial

2. Find the code for

as follows:

$r[filename]=$r[insertfile].$r[filetype];
Copy after login

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];
}
Copy after login

The modification is completed!

Additional explanation:

The code is as follows:

$mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf");
Copy after login

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!

Related labels:
source:www.word666.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!