Get the App
SLTechnology News&Howtos  ›  Servers  › 

Imperial CMS upload attachment naming how to realize the method of naming after the original file name

Shulou Source: shulou.com Published: 2022-06-02 02:02:00 10月03日 Update

Editor to share with you how the Imperial CMS upload attachment naming method to achieve the original file name, I hope you will learn a lot after reading this article, let's discuss it together!

Imperial CMS through the editor's upload attachment function to the last attachment, the original program will rename the attachment, the naming results are a long string of numbers + letters to name, this form of naming, for the user looks very uncomfortable, but also not conducive to us through FTP to adjust or replace the attachment. Therefore, sometimes we need to change the uploaded attachment to the rule named after the original file name, as follows:

Open the file\ e\ class\ connect.php

Found:

The code is as follows:

$r [filetype] = GetFiletype ($file_name)

Add the following:

The code is as follows:

$filename2=str_replace ($r [filetype],'', $file_name); / / get the file name with the suffix removed $mytype = array (".txt", ".rar", ".zip", ".doc", ".docx", ".xlsx", ".ppt", ".pdf"); / define the file type whose original name needs to be retained

Recommended to learn the Imperial cms course

Second, search

The code is as follows:

$r [filename] = $r [insertfile]. $r [filetype]

Modified to:

The code is as follows:

If (in_array ($r [filetype], $mytype)) {$r [filename] = $filename2. "_". $r [insertfile]. $r [filetype]; / / add the real file name to the front of the random code, separated by _,} else {$r [filename] = $r [insertfile]. $r [filetype];}

So far, the modification is complete!

Supplementary note:

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 a random code

. $r [filetype] this represents the file type

$filename2 represents the original file name.

After reading this article, I believe you have a certain understanding of the Imperial CMS upload attachment naming method to achieve the original file name, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: File attachment file name code empire method representative type article random code comfort function original name suffix letter finished that is form tutorial number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker Shulou Information Xiaomi Shulou Technology