Get the App
SLTechnology News&Howtos  ›  Servers  › 

Imperial CMS's method of naming attachments after the original file name

Shulou Source: shulou.com Published: 2022-06-02 05:07:43 10月04日 Update

Editor to share with you the method of Imperial CMS naming attachments after the original file name. I hope you will gain a lot after reading this article. Let's discuss it together.

How does Imperial CMS name attachments after the original file name?

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

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 Imperial CMS's method of naming attachments after the original file name. If you want to know more about it, welcome to follow the industry information channel. Thank you for your reading!

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