Home>Article>Backend Development> Solution to duplicate file names when uploading multiple images in tp5.0 (explanation with examples)

Solution to duplicate file names when uploading multiple images in tp5.0 (explanation with examples)

不言
不言 forward
2019-02-27 10:14:33 2703browse

The content of this article is about the solution to the duplicate file name of uploading multiple pictures in tp5.0 (explanation with examples). It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. helped.

Recently, a problem occurred while working on a project. Let’s record it here:

Problem:

Use the files that come with the TP5.0 framework After uploading the method, I found that the problem of duplicate file names may occur when uploading multiple images.

Problem code:

Find the TP5 framework upload file naming method, /thinkphp/library/think/File.php file, buildSaveName method (line 394);

case 'date': $savename = date('Ymd') . DS . md5(microtime(true)); break;

Solution:

The file naming method can be modified;

case 'date': //$savename = date('Ymd') . DS . md5(microtime(true)); $savename = date('Ymd') . DS . md5(uniqid(md5(microtime(true)),true)); break;

The above is the detailed content of Solution to duplicate file names when uploading multiple images in tp5.0 (explanation with examples). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete