亲爱的朋友们,我有一个简单的代码可以将一些图像移动到动态创建的文件夹中 这是我的代码
ini_set('max_execution_time', -1);
include("connection.php");
$sql = "SELECT manufacturers.id, user_profiles.logo
FROM `manufacturers`
INNER JOIN user_profiles
WHERE manufacturers.user_id = user_profiles.user_id AND manufacturers.id > 2235";
$query=mysqli_query($live_db, $sql) or die("Connection failed: " . mysqli_connect_error($live_db));
while($row = mysqli_fetch_array($query) ){
$temp = '/home/aigae4z5r/mydomain.com/frontend/web/uploads/manufacturers/images/'. $row['logo'];
$idDir = '/home/aigae4z5r/mydomain.com/frontend/web/uploads/manufacturers/'.$id;
$destinationPath = $idDir . DIRECTORY_SEPARATOR . $row['logo'];
if (!is_dir($idDir)) {
mkdir($idDir, 0777, TRUE);
}
if (rename($temp, $destinationPath)) {
echo 'moved! <br />';
} else {
echo 'failed <br />';
}
}
问题是创建新文件夹
if (!is_dir($idDir)) {
mkdir($idDir, 0777, TRUE);
}