Autor Zpráva
nemehlo
Profil *
jak zjistím mime souboru když nemohu použít mime_content_type()?, tedy u PHP < 4.3.0.
P3tr
Profil
Kdysi jsem resil neco podobneho, budes si muset napsat nejaky univerzalni detektor, pro kazdy content type jine nastaveni (identifikacni offset).
Ze content stringu si pak nactes hlavicku (u obrazku staci prvni 20 bajtu) a kontrolujes pres nejakou stringovou (substr) funkci jestli hlavicka obsahuje potrebnou identifikaci.

Prikladam takovy maly priklad jak to jde udelat s obrazkama:

function img_content_type($str) {
$default = 0; //neznamy typ
if (substr($str,0,3) == "GIF") {
return "image/gif";
}
if (substr($str,2,4) == "PNG") {
return "image/png";
}
if (substr($str,7,11) == "JFIF") {
return "image/jpeg";
}
if (substr($str,0,2) == "BM") {
return "image/bmp";
}
return $default;
}

Stejnym zpusobem muzes checkovat i dalsi soubory, zip, rar apod.
Doufam, ze to pomuze.

P.
nemehlo
Profil *
Šlape to jak hodinky, díky moc.
nemehlo
Profil *
jen bych tu měl jednu úpravičku

místo:

if (substr($str,7,11) == "JFIF")


raději:
if (substr($str,6,4) == "JFIF")
Toto téma je uzamčeno. Odpověď nelze zaslat.

0