Php 文件内容(cache/2016\u 02\u 13\u 10\u 00\u 00.gif):无法打开流:第74行中没有此类文件或目录

Php 文件内容(cache/2016\u 02\u 13\u 10\u 00\u 00.gif):无法打开流:第74行中没有此类文件或目录,php,Php,我读了一些关于这个错误的文章,但是我无法修复它。 我正在寻找一种方法来删除图像的背景,我得到了它,但我可以看到“计时器或倒计时”。 以下是php的代码: date_default_timezone_set('Europe/Paris '); include 'GIFEncoder.class.php'; $time = str_replace("/", " ", $_GET["dt"]); $future_date = new DateTime(date('r',strtotime(

我读了一些关于这个错误的文章,但是我无法修复它。 我正在寻找一种方法来删除图像的背景,我得到了它,但我可以看到“计时器或倒计时”。 以下是php的代码:

date_default_timezone_set('Europe/Paris '); 
include 'GIFEncoder.class.php';


$time = str_replace("/", " ", $_GET["dt"]);



$future_date = new DateTime(date('r',strtotime($time)));
$time_now = time();
$now = new DateTime(date('r', $time_now));

$f = "%a:%H:%I:%S";
$t = "second";

$frames = array();
$delays = array();

$cache_file = "cache/".preg_replace("/[^a-z,A-Z,0-9,_]/", "_", $time).".gif";

$img = imagecreatefrompng('background/1.png'); // bg
$black = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $black);
imagepng($img, $doo);
imagedestroy($img);

$shit = imagecreatefrompng('background/1.png'); // change background 
$delay = 100;
$font = array(
    'size'=>65, // font size
    'angle'=>0,
    'x-offset'=>30, // offset on x asis
    'y-offset'=>80, // offset on y asis
    'file'=>'fonts/PT_Sans-Web-Regular.ttf', // change font (example: handsean.ttf)
    'color'=>imagecolorallocate($shit, 255, 255, 255),
);

for($i = 0; $i <= 60; $i++){
    $interval = date_diff($future_date, $now);
    if($future_date < $now){

        $image = imagecreatefrompng($doo); // change background 
        $text = $interval->format('00:00:00:00');
        imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text );
        ob_start();
        imagegif($image);
        $frames[]=ob_get_contents();
        $delays[]=$delay;
        $loops = 1;
        ob_end_clean();
        break;
    } else {

        $image = imagecreatefrompng('background/1.png'); // change background 
        $text = $interval->format($f);

        if(preg_match('/^[0-9]\:/', $text)){
            $text = '0'.$text;
        }
        imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text );
        ob_start();
        imagegif($image);
        $frames[]=ob_get_contents();
        $delays[]=$delay;
        $loops = 0;
        ob_end_clean();
    }
    $now->modify('+1 '.$t);
}

$gif = new AnimatedGif($frames,$delays,$loops);
    file_put_contents($cache_file, $gif->getAnimation());

header( 'Expires: '.gmdate('D, d M Y H:i:s T', strtotime($time)) ); //expire this image
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
$gif->display();
我需要你的帮助和提示, 你好


PS:我不会说英语,但我尝试过:}

错误是不言自明的:没有文件或目录。在这种情况下,我认为没有目录“缓存”。也许如果你尝试绝对的道路,你会成功。使用相对路径时,目录与执行脚本的目录相同。看起来您有路径问题,因此文件内容无法写入服务器。或者需要将路径调整为完整路径,而不是相对路径。或者,可能是目录不可写(使用chmod)。这就是当您在不了解代码位的情况下将代码位复制/粘贴到一起时发生的情况。
    [11-Feb-2016 20:37:35 America/New_York] PHP Warning:  file_put_contents(cache/2016_02_13_10_00_00.gif): failed to open stream: No such file or directory in /home/iedgmnuq/public_html/./count/index.php on line 74
[11-Feb-2016 20:37:35 America/New_York] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/iedgmnuq/public_html/./count/index.php:26) in /home/iedgmnuq/public_html/./count/index.php on line 76
[11-Feb-2016 20:37:35 America/New_York] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/iedgmnuq/public_html/./count/index.php:26) in /home/iedgmnuq/public_html/./count/index.php on line 77
[11-Feb-2016 20:37:35 America/New_York] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/iedgmnuq/public_html/./count/index.php:26) in /home/iedgmnuq/public_html/./count/index.php on line 78
[11-Feb-2016 20:37:35 America/New_York] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/iedgmnuq/public_html/./count/index.php:26) in /home/iedgmnuq/public_html/./count/index.php on line 79
[11-Feb-2016 20:37:35 America/New_York] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/iedgmnuq/public_html/./count/index.php:26) in /home/iedgmnuq/public_html/./count/index.php on line 80