PHP düzeltme görüntü bayt

0 Cevap php


I'm gonna strart with my use case, before i'll explane the problem i'm running in to.

I'm building a mobile application using the phonegap framework.
For this application i need to upload a file (a picture made with a camera).
On most platforms i can get this image back as a base64 encoded image.
I can send this back to the server, and it can decode it and save it. (and do some other funcy stuff as it's a QR code).

Now on symbian, i can't get back the base64 string, and i can only get the URI to the image. This isn't a problem, becouse i can use a xmlhttprequest to get the image data and encode it to base64 using javascript.

This methode works, but it gives me a problem.
The symbian browser appears to have a bug. It's a webkit based browser from 2005 (yes, it's that old, even on the newest s60 phones).
The bug is that it converts all characters that it doesn't know (not in an utf-8 table) to 2 bytes. If is remember correctly it was everything above 127.

Ben javascript kullanarak bu hatayı düzeltmek için denedim, ama hayır gitmek (btw, tuval ve sonra getBinaries veya tuval 2d tarayıcı tarafından desteklenmiyor olarak desteklenmez böyle bir şey) oldu.

So, i try to build a workaround in php to fix the bytes. This is what i have right now, though it's not working:

function getValidBin($bin, $offset = 0) {
    $binLength = sizeof($bin);
    for ($i = $offset; $i<=$binLength; $i++) {
        if ($i == $binLength) {
            return false;
        }
        if ($bin[$i] < 127) {

            $binT = $bin[$i] + $bin[$i+1];
            $bin2 = $bin;
            $bin2[$i] = $binT;
            $bin2[$i+1] = null;
            if (imagecreatefromstring($bin2) != false) {
                return $bin2;
            } else {
                $bin3 = getValidBin($bin2, $i);

                if ($bin3 != false) {
                    return $bin3;
                }
            }
        }
    }
}

This function is not working for some reason. I get the following warnings:

Uyarı: imagecreatefromstring () [function.imagecreatefromstring]: Veri hattı 98 / opt / içerik / erik / OMNICOL / HTML / WS / services / qrDecoder / QrDecoder.php tanınan bir biçimde değil

Ve ben alıyorum:

Ölümcül hata: '100 'Maksimum fonksiyonu yuvalama seviyesi durduruluyor ulaştı! hattında 87 / opt / içerik / erik / OMNICOL / HTML / WS / services / qrDecoder / QrDecoder.php içinde

Oldukça kolay çözmek için bu sonuncusu, sanırım, ama ben i'de yine de göndermek düşünüyorum.

Now, my question are:
Am i on the right track?
How do i solve the warning?

Thanks a lot in advance,
Erik

p.s. sorry if my english is bad. I'm not a native speaker, as i'm dutch.
p.s.2 The bug i was talking about is this one: http://markmail.org/message/iosbn3rbcgu5k6qt

EDIT: The solution for the max of 100 depth was harder then i thought it would be. So help on that would be great too.

0 Cevap