Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP ImageCreateFromJPEG()不允许我重新创建图像:它只生成一次图像并保存在服务器中';不管发生什么事,我们都会缓存_Php_Image_Caching - Fatal编程技术网

使用PHP ImageCreateFromJPEG()不允许我重新创建图像:它只生成一次图像并保存在服务器中';不管发生什么事,我们都会缓存

使用PHP ImageCreateFromJPEG()不允许我重新创建图像:它只生成一次图像并保存在服务器中';不管发生什么事,我们都会缓存,php,image,caching,Php,Image,Caching,我使用ImageCreateFromJPEG()在php中创建一个图像,并用一些文本填充它 我的问题是,创建映像后,即使我从服务器中删除它,并删除缓存,映像仍然存在 即使我更改了应该放在图像内部的文本,也不会更改任何内容。我尝试使用不同的浏览器(以防浏览器缓存出现问题),但问题仍然存在 这是我生成图像的代码: function demo($userID, $cursoID, $fechaAprobacion) { $x = $conectar->prepare(" SELECT fe

我使用ImageCreateFromJPEG()在php中创建一个图像,并用一些文本填充它

我的问题是,创建映像后,即使我从服务器中删除它,并删除缓存,映像仍然存在

即使我更改了应该放在图像内部的文本,也不会更改任何内容。我尝试使用不同的浏览器(以防浏览器缓存出现问题),但问题仍然存在

这是我生成图像的代码:

function demo($userID, $cursoID, $fechaAprobacion) {

$x = $conectar->prepare("
  SELECT fechaEmisionCertificado, cursosUsuarios.userID, userNombres, tipoCertificado, campoExtraCertificado, userDNI,
      nombreCurso
  FROM cursosUsuarios
  JOIN usuarios
  ON cursosUsuarios.userID = usuarios.userID
  JOIN cursos 
  ON cursosUsuarios.cursoID = cursos.cursoID
  WHERE cursosUsuarios.userID = ?
  AND cursosUsuarios.cursoID = ?
  ");
$x->bindParam(1, $userID);
$x->bindParam(2, $cursoID);
$x->execute();
$y = $x->fetch(PDO::FETCH_ASSOC);

$tipoCertificado = $y['tipoCertificado'];
$campoExtraCertificado = $y['campoExtraCertificado'];
$nombreCompleto = strtolower($y['userNombres']);
$nombreCurso = $y['nombreCurso'];

$fechaNumeros = $y['fechaEmisionCertificado'];

$guardarImagen = '/userID'.$userID.'-cursoID'.$cursoID.'.jpg';

$mesyAnoEmision = $mesEmision.' de '.$anoEmision.'.';

//Now we print the certificate, according to the certificate type $tipoCertificado

    if ($tipoCertificado == 4) { //taller online
      $imagen = ImageCreateFromJPEG('certificado-taller-online-2018.jpg');
      //Color de fondo de la imagen
      $color = imagecolorallocate($imagen, 0, 0, 0);  
      //cargamos las fuentes ttf
      $f = '/mtcorsiva.ttf';
      $f2 = '/JosefinSans-BoldItalic.ttf';

      //tomamos la data y la incrustamos
      // horizontal / vertical
      imagettftext($imagen, 140, 0, 850, 733, $color, $f, $nombreCompleto);
      imagettftext($imagen, 80, 0, 1555, 879, $color, $f, $nombreCurso);
      imagettftext($imagen, 90, 0, 1590, 1218, $color, $f, $fechaAprobacion);
      imagettftext($imagen, 90, 0, 980, 1805, $color, $f, $diaEmision);
      imagettftext($imagen, 90, 0, 1879, 1805, $color, $f, $mesyAnoEmision);
      imagettftext($imagen, 40, 0, 3122, 2314, $color, $f2, $userID);
      //Header y output
      header('Content-type: image/jpeg');
      //guardamos la imagen como archivo
      imagejpeg($imagen,$guardarImagen,100);
      //mostramos la imagen
      imagejpeg($imagen,NULL,100);
      imagedestroy($imagen);    
    }

}


demo($userID, 1, 'December 19th');

为了以防万一,我发现了一个问题:

问题是,尝试显示的新图像没有设置权限,因此当我尝试显示它时,它不会显示,而是显示旧图像

所以我应该先设置他们的权限,然后显示:

chmod($imagen, 0777);
imagejpeg($imagen,NULL,100);

如果你要投否决票,请告诉我为什么,这样我可以改进我的问题。谢谢