PHP上传文件改名,哪位高手帮助修改一下
PHP上传文件改名,谁帮助修改一下
下面的代码只是接受上传,谁给加个以时间修改源文件名字的代码啊谢谢。
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['sub']))
{
$myfile=$_FILES["myfile"];
$myfileType = substr($myfile['name'], strrpos($myfile['name'], ".") + 1);
if ($myfile['size'] > $maxSize)
{
$result = 1;
}
else if (!in_array($myfileType, $fileTypes))
{
$result = 2;
}
elseif (is_uploaded_file($myfile['tmp_name']))
{
$toFile = $uploadDir . '/' . $myfile['name'];
if (@move_uploaded_file($myfile['tmp_name'], $toFile)) {
{
$result = 0;
}
else
{
$result = -1;
}
}
else
{
$result = 1;
}
}
?>
------解决方案--------------------
$toFile = $uploadDir . '/' . $myfile['name'];
这是目标文件名
自己改一下就是了
------解决方案--------------------
$date = date('YmdHis',time());
$toFile = $uploadDir . '/'.$date . $myfile['name'];
好人做到底

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

OOBELANGUAGE Error Problems in Windows 11/10 Repair

How to enable or disable taskbar thumbnail previews on Windows 11

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
