ziedinjsh Posted July 23, 2012 Report Share Posted July 23, 2012 Nevaru saprast <?php $name = $_FILES['photo']['name']; $tmp_name = $_FILES['photo']['tmp_name']; $size = $_FILES['photo']['size']; $type = $_FILES['photo']['type']; $ext = explode(".", strtolower($name)); $ext = substr($name, strrpos($name, '.')+1); $allowed = array("image/jpg", "image/jpeg", "image/gif", "image/png"); if(!in_array($type, $allowed)) { echo $ext; }else{ echo $name."<br>"; echo $tmp_name."<br>"; echo $size."<br>"; echo $type."<br>"; echo $ext.""; } ?> kad izvēlos bilžu formātu viss ir ok.. parāda informāciju ko prasu. izvēlos txt formātu parāda tikai faila formātu, bet kad izvēlos mp3 failu man rāda notices par 2,3,4,5 rindiņu! Kapēc??? Quote Link to comment Share on other sites More sharing options...
briedis Posted July 23, 2012 Report Share Posted July 23, 2012 (edited) Un kādus notice tad rāda? ..varu derēt, ka rāda undefined index notice, jo fails netika ielādēts, jo max upload size ir uzstādīts mazāks par tipiska mp3 izmēru. Ko darīt? Pirms ķeries pie faila apstrādes, pārliecinies, vai tas vispār ir ielādēts. Edited July 23, 2012 by briedis Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted July 23, 2012 Author Report Share Posted July 23, 2012 ā, ja man nav norādīts maximālais faili izmērs tad viņš failu neielādē? tad es laikam saprotu kas pa vainu! Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted July 23, 2012 Author Report Share Posted July 23, 2012 hmm, bet man ir norādīts max file size <form method="post" action="process/image.process.php" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="83886080"> <input type="file" name="photo"> <input type="submit" value="Ok"> </form> un php.ini man arī ir norādīts daudz lielāks file size limits nekā mp3 fails Quote Link to comment Share on other sites More sharing options...
briedis Posted July 23, 2012 Report Share Posted July 23, 2012 Tas nemaina būtību, ka tev vispirms ir jāpārbauda, vai fails tika ielādēts. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted July 23, 2012 Author Report Share Posted July 23, 2012 pag, kā tad to var pārbaudīt? Quote Link to comment Share on other sites More sharing options...
briedis Posted July 23, 2012 Report Share Posted July 23, 2012 ever heard of google? Ja nu galīgi sūdīgi ar atslēgvārdiem angliski, var izmantot google translate: http://translate.google.com/#lv|en|PHP%20p%C4%81rbaud%C4%ABt%20vai%20fails%20ir%20aug%C5%A1upiel%C4%81d%C4%93ts Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 23, 2012 Report Share Posted July 23, 2012 pag, kā tad to var pārbaudīt? $_FILES['fails']['error'] -> tiek nodoti visi parametri. par potencialo kļudu, 0 nav kļuda , parējos kļudas indeksus meklē pats ( norāda kāpēc neizdevās uplādot .. ) Quote Link to comment Share on other sites More sharing options...
briedis Posted July 23, 2012 Report Share Posted July 23, 2012 GreyWolf, potenciāls undefined index, ja fails netika ielādēts. Lai iegūtu faila paplašinājumu, lietojam šo funkciju: http://php.net/manual/en/function.pathinfo.php Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 23, 2012 Report Share Posted July 23, 2012 (edited) GreyWolf, potenciāls undefined index, ja fails netika ielādēts. Kāpēc?? indekss jau padodas šā vai tā ar POST ... idejiski būs konkrēts kļūdas numurs, fails par lielu, fails netika saglabāts uz servera utt... šeit sīkāk edit: vispār vienmēr ir vēlams pārbaudīt vai pie faila ielādes nav kļūda, šādi var viegli izķert ja fails ir pārāk liels, vismaz var userim atmest atpakaļ sakarīgu error mesāgi ... Edited July 23, 2012 by Grey_Wolf 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.