-2

I use LiipImagineBundle for re-size my image after upload. I have a error when I tried to upload some Jpeg about HTML encodage.

With jpeg form my camera that's work, but not form my phone camera.

What my browser show only js error and return blank page ?

I didn't understand what is that error.

Full message in french :

L'encodage de caractères du document HTML n'a pas été déclaré. Le document sera affiché avec des caractères incorrects 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.

controller 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;
}

I have found help to create my compress Function here.

I tried to catch some Exception but nothing work.

Someone have a solution ?

Sorry for my English, I am learning it...

4

1 回答 1

0

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

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

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

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

祝你今天过得愉快。此致

于 2015-04-21T12:36:04.430 回答