-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...

Community
  • 1
  • 1
olive007
  • 760
  • 1
  • 12
  • 32

1 Answers1

0

It may be a little bit anoying but have you set default_charset to "UTF-8" in your php.ini ? If you use Apache: Is (AddDefaultCharset UTF-8) present on your httpd.conf ?

In your view: is is présent on between your HTML Header.

Check the encoding of your editor to UTF-8 without BOM if it's not configured yet and save all file you have generated with that correct charset.

If not this may be the origin of that bad behavior.

Have a nice day. Best Regards

Mehdi Aïssani
  • 111
  • 1
  • 5