anonīms Posted February 6, 2008 Report Share Posted February 6, 2008 Lieta tāda, ka vienai lapai ir uzmesta "Shopping sistēma" - kaut kas līdzīgs katalogam. Kad no administrācijas paneļa mēģina izveidot kategoriju, tad viss sanāk, bet bildi gan viņš neaplodo, bet arī nekādu erroru neizmet. // if a file is given if (trim($image['tmp_name']) != '') { // get the image extension $ext = substr(strrchr($image['name'], "."), 1); // generate a random new file name to avoid name conflict $imagePath = md5(rand() * time()) . ".$ext"; // check the image width. if it exceed the maximum // width we must resize it $size = getimagesize($image['tmp_name']); if ($size[0] > MAX_CATEGORY_IMAGE_WIDTH) { $imagePath = createThumbnail($image['tmp_name'], $uploadDir . $imagePath, MAX_CATEGORY_IMAGE_WIDTH); } else { // move the image to category image directory // if fail set $imagePath to empty string if (!move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath)) { $imagePath = ''; } } } Šis ir img upload kods. Kad kategorija ir izveidota, tad paņemot img src rādas - ... /images/category/ce11af5068e78bf2751cd80cf1f61451.jpg (Bilde tika uplodota ar pavisam citu nosaukumu). Link to comment Share on other sites More sharing options...
andrisp Posted February 6, 2008 Report Share Posted February 6, 2008 Nu ? Kods ģenerē jaunu nosaukumu. Link to comment Share on other sites More sharing options...
Aleksejs Posted February 6, 2008 Report Share Posted February 6, 2008 Jā, jo faila nosaukums tiek veidots šitā: $imagePath = md5(rand() * time()) . ".$ext"; Link to comment Share on other sites More sharing options...
anonīms Posted February 6, 2008 Author Report Share Posted February 6, 2008 Hm, bet, kas tad varētu būt par iemeslu, ka bilde neaplodojos? Link to comment Share on other sites More sharing options...
andrisp Posted February 6, 2008 Report Share Posted February 6, 2008 Ieslēdz error_reportingu. Link to comment Share on other sites More sharing options...
anonīms Posted February 6, 2008 Author Report Share Posted February 6, 2008 Tur jau tā lieta, ka viņu ieslēdzot errori tāpat nav. Link to comment Share on other sites More sharing options...
andrisp Posted February 6, 2008 Report Share Posted February 6, 2008 move_uploaded_file atgriež true vai false ? Sabāz visās malās echo 'bla' utt un skaties, kurš kods izpildās un kurš ne, cik tālu tiek utt. Link to comment Share on other sites More sharing options...
Aleksejs Posted February 6, 2008 Report Share Posted February 6, 2008 (edited) šito: // move the image to category image directory // if fail set $imagePath to empty string if (!move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath)) { $imagePath = ''; pārveido par šito: // move the image to category image directory // if fail set $imagePath to empty string if (!move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath)) { $imagePath = ''; echo 'viss ir slikti, būs vēl sliktāk!' P.S. A kā Tu slēdz iekšā to error_reporting? P.P.S. Vai ir tiesības rakstīt tajā mapē webservera lietotājam? P.P.P.S. Un šito izlasi - šos errorus izskatās, ka vispār nepārbaudi: http://lv.php.net/manual/en/features.file-upload.errors.php Edited February 6, 2008 by Aleksejs Link to comment Share on other sites More sharing options...
anonīms Posted February 6, 2008 Author Report Share Posted February 6, 2008 #1 P.S - Apmēram tā error_reporting(1); error_reporting(E_ERROR | E_WARNING | E_PARSE); error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL); ini_set('error_reporting', E_ALL); #2. P.P.S - WTF? :DDDD VISS IET. Paldies :) Buča no mana suņa tev Link to comment Share on other sites More sharing options...
Kavacky Posted February 6, 2008 Report Share Posted February 6, 2008 MEGALOL. Link to comment Share on other sites More sharing options...
Aleksejs Posted February 6, 2008 Report Share Posted February 6, 2008 Nja... Nu, vismaz no suņa... :P Link to comment Share on other sites More sharing options...
Paulinjsh Posted February 6, 2008 Report Share Posted February 6, 2008 njā, tā uzsetotu error_reporting vēl nebiju redzējis! pietiek tā: error_reporting(E_ALL); ini_set('display_errors', 1); Link to comment Share on other sites More sharing options...
Recommended Posts