10

WordPress上传文件自动重命名

 3 years ago
source link: https://www.isaced.com/post-212.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

WordPress上传文件自动重命名

WordPress上传文件默认是不改变文件名称的,可对中文文件名而言,某些系统、某些浏览器访问是会出现问题滴,那么怎样让Wordpress上传文件自动重命名呐?

以wordpress 3.5.1 为例,打开“wp-admin/includes/file.php”文件,找到第330行左右这段代码:

// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
    return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/".date("YmdHis").floor(microtime()*1000).".".$ext; 
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
    		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );

保存,重新上传文件。这样,新上传的文件,就会自动保存为“年月日时分秒+千位毫秒整数”的新文件名,并保存到相应的年月文件夹之下了。

如:“20130622162751444.jpg


Recommend

  • 31

  • 10
    • developer.51cto.com 4 years ago
    • Cache

    移动并重命名2000个文件,Python,3秒

    大家好,又到了Python办公自动化(偷懒)专题。 今天介绍的案例是如何利用Python来自动化移动、修改、重命名文件/夹,这样的操作在日常办公中经常会用到,若能掌握用Python实现将会大大提高效率! 所以我希望能够通过这篇文章来让大家了解...

  • 6
    • www.chenwenguan.com 4 years ago
    • Cache

    Python批量重命名压缩文件

    Python批量重命名压缩文件 2021年1月19日 | 最近更新于 下午7:35工作上遇到一个问题,QA提供的1000多个压缩文件名称命名不规范,服务器做C++覆盖率产物解析,压缩文件文件名必须和解压之后的文件名一致,所以只是修改压缩文件名称行不通,...

  • 12

    WordPress上传文件大小限制修改 最后更新 : 2020.01.30   WordPress上传媒体文件默认大小限制是2M...

  • 4
    • www.lujun9972.win 3 years ago
    • Cache

    使用rename批量重命名文件

    使用rename批量重命名文件 在linux上我们一般用 mv 命令来对文件进行重命名操作,但是 mv 一次只能对一个文件进行重命名,对批量文件进行重命名就比较麻烦了。 一直以来我都是写一段shell循环或者跟 xargs...

  • 9

    V2EX  ›  Linux 如何理解 mv 重命名改变了文件的 ctime?   lolcat · 2 小时 26 分钟前 · 338 次点...

  • 3
    • www.myfreax.com 2 years ago
    • Cache

    如何在Linu中重命名文件和目录

    linux 如何在Linu中重命名文件和目录 重命名文件和目录是您经常需要在Linux系统上执行的最基本任务之一。重命名单个文件很简单,但一次重命名多个文件可能是一个...

  • 8
    • lenciel.com 2 years ago
    • Cache

    用 zmv 批量重命名文件

    我看电影主要靠下载1。 这些年,好的电影网站越来越少:因为版权管得严了,似乎没啥好抱怨的。 还在经营的,很多都会在压片子的时候,加...

  • 6

    rename Linux rename命令重命名多个文件与目录 使用mv命令重命名多个文件和目录可能是一个乏味的过程,因为它涉及使用管道 ...

  • 5
    • www.myfreax.com 2 years ago
    • Cache

    wget 下载文件并重命名

    wget wget 下载文件并重命名 GNU Wget是一个命令行程序,用于从 Web 站点下载文件

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK