我有一个code.php
文件类似下面其中在all-photos
文件夹生成像-this-is-a-test-21.jpg
图像。如何将文件夹名称(../../../)添加到PHP中的图像名称中?
foreach($original_images as $new_image) {
---> some coding here
$image_prefix_original = "-this-is-a-test-";
$rand = rand(1,100);
---> some coding here also
imagejpeg($new_image, $image_prefix_original .$rand.'.jpg');
}
假设我执行code.php
文件为http://localhost/tests/photos-test/all-photos/code.php
。我的问题是如何生成图像名称,如tests-photos-test-all-photos-this-is-a-test-21.jpg
而不是-this-is-a-test-21.jpg
。
我不明白,你是否要求你的目录分隔符是连字符? –
在大多数安装中,'DIRECTORY_SEPARATOR'通常是'/'。你有没有指定它是'-'? – BenM
您不能在文件名中使用系统目录分隔符。 –