Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report