0
所以我有一个名为“names.txt”的文件用多行。每行包含一个名称。 我也有一个样机图像名为“participant.jpg”用php创建多个图像
在这里它了我的代码:
<?php
$handle = fopen("names.txt", "r");
function create_img($line)
{
$im = imagecreatefromjpeg("./images/participant.jpg");
$textcolor = imagecolorallocate($im, 0, 0, 0);
// Write the string at the top left
imagettftext($im, 50, 0, 80, 640, $textcolor, 'nexa.ttf', $line);
imagejpeg($im, './uploads/' . $line . '.jpg');
imagedestroy($im);
}
if ($handle) {
while (($line = fgets($handle)) !== false) {
create_img($line);
}
} else {
die('Cannot open file..');
}
?>
所以对于每一个新行我想创建一个特定的照片和“上传”它我的上传文件夹。
,只为最后一行创建的图像和其余它返回我这个错误:
Warning: imagejpeg() [<a href='function.imagejpeg'>function.imagejpeg</a>]: Unable to open './uploads/Botond.jpg' for writing: Invalid argument in C:\lab\ccc-badges\badges.php on line 12
这是一些$线输出
Alina Popescu
Adrian Oltean
Patricia-Andrada Leven
Stanescu Gheorghe
尝试在第12行之前创建名称为'./uploads /'.$ line。'。jpg''的新文件 – kamil09875
wat是最后一行和其他行之间的差异吗? –
没有区别..只是这是最后一行 – smotru