[英]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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.