Git Product home page Git Product logo

Comments (1)

qakcn avatar qakcn commented on July 18, 2024 1

抱歉这么久才回复。

对于文件名的处理,都在includes/functions.upload.php中,有如下几处:

扩展名处理

主要是根据MIME类型统一扩展名,同时也是一个安全处理,避免非图片文件上传。

位置在第71行到96行,以及159到184行,两处的代码是一样的。

文件重命名处理

主要是针对重名文件,98行和187行都调用了·rename_if_exists·函数,该函数在249行到276行。

这里返回的就是最终的文件名,在下一行(99行和188行)就和上传目录拼接成最终的保存路径。


所以你要实现随机命名的话,可以修改·rename_if_exists·,该函数传入原文件名以及上传目录,返回新文件名(不包含上传目录)。

亦可修改98行和187行,调用你自己的文件名处理函数。在99行或188行之前处理文件名即可。

from qchan.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.