无法加载资源。服务器错误500

时间:2016-06-21 13:38:00

标签: php caching path directory

我有以下代码,用作以下page

中的缓存类的示例    
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Image Cache Test</title>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <style>
        body {
            font-family: 'Open Sans', Helvetica, Arial, sans-serif;
        }
        img {
            max-width: 100%;
        }
    </style>
</head>
<body>
    <?php
        $imagecache = new ImageCache();
        $imagecache->cached_image_directory = dirname(__FILE__) . '../';
        $cached_src_one = $imagecache->cache( 'background.jpg' );
        echo '<p>Original file size: ' . filesize($imagecache->image_src) . ' bytes</p>';
        echo '<p>PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes</p>';
        echo '<p>Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%</p>';
    ?>
    <img src="<?php echo $cached_src_one; ?>" alt="">
    <hr>
    <?php
        $imagecache->check_link_cached = false;
        $cached_src_two = $imagecache->cache( 'background.jpg' );
        echo '<p>Original file size: ' . filesize($imagecache->image_src) . ' bytes</p>';
        echo '<p>PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes</p>';
        echo '<p>Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%</p>';
    ?>
    <img src="<?php echo $cached_src_two; ?>" alt="">
    <hr>
    <?php
        $cached_src_two = $imagecache->cache( 'http://placehold.it/350x350' );
        echo 'Original file size: ' . filesize($imagecache->image_src) . ' bytes<br>';
        echo 'PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes<br>';
        echo 'Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%';
    ?>
    <p>Because the "compressed" file size is larger than the original, a local copy of the original file will be server instead.</p>
    <img src="<?php echo $cached_src_two; ?>" alt="">

</body>
</html>

我收到了上述错误,不确定是否必须对代码执行某些操作。在路径方面,一切都是相对的。

0 个答案:

没有答案