如何将图片上传到单独的文件夹?
How to upload images to separate folders?
如何将表格中插入的图片上传到服务器,每次新上传都会在主目录中创建新文件夹并将其命名为例如 i1、i2、i3...?
现在我上传的内容正在保存到主文件夹中,所以我需要将其分开。
$targetDir = "images/";
$fileName = basename($_FILES["file"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
您可以使用函数创建文件夹,并将其添加到您的 php 代码中
if (!file_exists('path/to/directory')) {
mkdir('path/to/directory', 0777, true);
}
如何将表格中插入的图片上传到服务器,每次新上传都会在主目录中创建新文件夹并将其命名为例如 i1、i2、i3...?
现在我上传的内容正在保存到主文件夹中,所以我需要将其分开。
$targetDir = "images/";
$fileName = basename($_FILES["file"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
您可以使用函数创建文件夹,并将其添加到您的 php 代码中
if (!file_exists('path/to/directory')) {
mkdir('path/to/directory', 0777, true);
}