labaiss Posted July 21, 2010 Report Share Posted July 21, 2010 $faila_paplasinajums = pathinfo($file, PATHINFO_EXTENSION); // iegustam faila paplashinaajumu $faila_paplasinajums2 = strtolower($faila_paplasinajums); // pārvēršam informāciju mazajos burots problēma sekojoša: faila paplašinājums jāpārvērš mazajos burtos! bet strtolower acīmredzmi man neder&nestrādā. jo pēc tam kad switch izvēlas - viņš izvēlas tikai mazos burtus un nerakstīs jau divus CASE ar lieliem un maziem! switch ($faila_paplasinajums2) { case gif: dfdsgsdgf break; case jpeg: PAAALDIES! Quote Link to comment Share on other sites More sharing options...
briedis Posted July 21, 2010 Report Share Posted July 21, 2010 Kāpēc tad neder? :D Quote Link to comment Share on other sites More sharing options...
labaiss Posted July 21, 2010 Author Report Share Posted July 21, 2010 Kāpēc tad neder? :D :D :D jaa biju kļūdijies tā pamatīgi!! visus formātus saliku izņemot jpg, kas bija dominējošais!! Muļķīgi, bet neko darīt! :D Paldies! Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 21, 2010 Report Share Posted July 21, 2010 (edited) Kāpēc tad neder? :D Pilnibaa piekriitu... kapec neder? bet vispar .. Kljuda nav tur bet gan pashaa SWICH konstrukcija switch ($faila_paplasinajums2) { case gif: dfdsgsdgf break; case jpeg: Un switch ($faila_paplasinajums2) { case "gif": echo 'Gifelis'; break; case "jpeg": echo 'Jepega'; break; default: echo 'defoltais'; Izjuti atskjiriibu ??? P.S. ja nemani neko savadaku, tad programmesana nav prieks tevis... Edited July 21, 2010 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
labaiss Posted July 21, 2010 Author Report Share Posted July 21, 2010 (edited) Pilnibaa piekriitu... kapec neder? bet vispar .. Kljuda nav tur bet gan pashaa SWICH konstrukcija switch ($faila_paplasinajums2) { case gif: dfdsgsdgf break; case jpeg: Un switch ($faila_paplasinajums2) { case "gif": echo 'Gifelis'; break; case "jpeg": echo 'Jepega'; break; default: echo 'defoltais'; Izjuti atskjiriibu ??? P.S. ja nemani neko savadaku, tad programmesana nav prieks tevis... Izjūti atšķirību, kāds bija jautājums un kāda bija tava atbilde? Un ja tu te esi atnācis noniecināt un vēl kaut ko darīt - TAD PROGRAMMĒŠANA NAV priekš tevis! :D :D Pašam smiekli nenāk? :D P.S. Ja nesaproti jautājumu, tad neatbildi uz to!!! Edited July 21, 2010 by labaiss Quote Link to comment Share on other sites More sharing options...
marcis Posted July 21, 2010 Report Share Posted July 21, 2010 (edited) Pofig extensionu.. $info = getimagesize($file); switch($info[2]){ case IMAGETYPE_JPEG: $src = imagecreatefromjpeg($file); break; case IMAGETYPE_GIF: $src = imagecreatefromgif($file); break; // ... default: return false; break; } http://lv.php.net/manual/en/image.constants.php Edited July 21, 2010 by marcis Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 21, 2010 Report Share Posted July 21, 2010 (edited) Pašam smiekli nenāk? :D P.S. Ja nesaproti jautājumu, tad neatbildi uz to!!! neliekas ka STRING jaliek pedinjas?? tur ari bija atskjiriiba... P.S. piedevam noraadiju, ka tavs jautajums ir nevietaa, jo idejiski viss bija pareizi (parverst uz Lover/Uper varjanu -> novienadot) Bet ka, kljuda ir pashaa SWICH konstrukcijaa ( kas arii izradijas patiesiiba [mazliet citaa varjanta, bet tomer tieshi tur] ) Edited July 21, 2010 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
mixis Posted July 21, 2010 Report Share Posted July 21, 2010 tikai piebilde. Var arī izmantot vienu mainīgo, ne divus. $faila_paplasinajums = strtolower($faila_paplasinajums) Quote Link to comment Share on other sites More sharing options...
sheps Posted July 23, 2010 Report Share Posted July 23, 2010 (edited) failam parasi ir arī kkāds nebūt tips piem, es izmantoju šādu variantu, caur $_FILES masīvu: $type = $_FILES["bilde"]["type"]; $picType = ''; switch($type){ case 'image/pjpeg': case 'image/jpeg': $picType = 'jpg'; break; case 'image/gif': $picType = 'gif'; break; case 'image/png': $picType = 'png'; break; } tālāk jau veidojot bildi tev būs paplašinājums ar maziem burtiem ko arī pievienosi jaunajai bildei.. Edited July 23, 2010 by sheps Quote Link to comment Share on other sites More sharing options...
marcis Posted July 23, 2010 Report Share Posted July 23, 2010 $_FILES masīva type vērtībai uzticēties nav pilnīgi nekādas jēgas... Es paņemu jebkuru failu, uzlieku extensionu .jpg un $_FILES['blah']['type'] man uzreiz rāda image/jpeg. Ja izmantojam flash upload, tad vienmēr type būs application/octet-stream. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.