【问题标题】:LiipImagineBundle Error encodage HTMLLiipImagineBundle 错误编码 HTML
【发布时间】:2015-04-20 21:42:08
【问题描述】:

我使用LiipImagineBundle 在上传后重新调整我的图像大小。当我尝试上传一些关于 HTML 编码的 Jpeg 时出现错误。

使用 jpeg 格式的相机可以工作,但不能形成我的手机相机。

什么我的浏览器只显示js错误并返回空白页?

我不明白那个错误是什么。

法语全文:

L'encodage de caractères du document HTML n'a pas été déclaré。 Le document sera affiché avec des caractères wrongs pour certaines configurations de navigateur si le document contient des caractères en dehors de la plage US-ASCII。 L'encodage de caractères de la page doit être déclaré dans le document ou dans le protocole de transfert。

控制器 Symfony2

private function compressFile($file) {
    $path = $file->getWebPath();
    $absPath = $file->getAbsolutePath();
    $tmpPath = $absPath."tmp";
    $filter = "image";

    $container = $this->container;
    $dataManager = $container->get('liip_imagine.data.manager');
    $filterManager = $container->get('liip_imagine.filter.manager');

    try {
        $image = $dataManager->find($filter, $path);
        $response = $filterManager->applyFilter($image, $filter);
        //$response = $filterManager->get($this->getRequest(), $filter, $image, $path);
        $fileCompressed = $response->getContent();
    }
    catch (\Exception $e) {
        return "error";
    }

    $f = fopen($tmpPath, 'w');
    fwrite($f, $fileCompressed);
    fclose($f);

    unlink($absPath);
    rename($tmpPath, $absPath);

    return null;
}

我找到了创建压缩函数 here 的帮助。

我试图捕捉一些异常,但没有任何效果。

有人有解决办法吗?

对不起我的英语,我正在学习它......

【问题讨论】:

    标签: php html symfony encoding liipimaginebundle


    【解决方案1】:

    这可能有点烦人,但是您是否在 php.ini 中将 default_charset 设置为“UTF-8”? 如果您使用 Apache: (AddDefaultCharset UTF-8) 是否存在于您的 httpd.conf 中?

    在您看来:is 存在于您的 HTML Header 之间。

    如果尚未配置,请检查您的编辑器的编码是否为 UTF-8 而没有 BOM,并使用正确的字符集保存您生成的所有文件。

    如果不是,这可能是不良行为的根源。

    祝你有美好的一天。 最好的问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多