Mighty Posted July 1, 2009 Report Share Posted July 1, 2009 Man vajadzētu uzzināt kā lai es varu pārbaudīt vai dotajā (avatara) adresē norādītā bilde eksistē? Man ir getimagesize funkcija, bet ja kāds bildes vietā ieraksta kaučkādu štruntu ( piem "gejs"), tad lapa bildes ignorēšanas vietā izmet diezgan pretīga izskata erroru - Warning: getimagesize(gejs) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\ . Tātad, es gribētu vispirms pārbaudīt vai dotā bilde eksistē - un tad, ja tā eksistē, lai nostrādā getimagesize. Link to comment Share on other sites More sharing options...
waplet Posted July 1, 2009 Report Share Posted July 1, 2009 if(file_exists(gejs)){ ir vairs } else { nav fails } Link to comment Share on other sites More sharing options...
Mighty Posted July 1, 2009 Author Report Share Posted July 1, 2009 Nez, negrib avatars printēties. $avatars1 = htmlspecialchars($user["avatar"]); if ($user["avatar"]) { if(file_exists( $avatars1)){ $width =getimagesize($user["avatar"]); $maxwidth = 500; if ($width[0] > $maxwidth) print("<tr><td class=rofl4>".Avatar."</td><td class=rofl3 td align=left><img width=\"$maxwidth\" src=\"" . htmlspecialchars($user["avatar"]) . "\"></td></tr>\n"); else print("<tr><td class=rofl4>".Avatar."</td><td class=rofl3 td align=left><img src=\"" . htmlspecialchars($user["avatar"]) . "\"></td></tr>\n"); } else {} } Nevari fiksi apskatīties, kas varētu nebūt tā? Link to comment Share on other sites More sharing options...
waplet Posted July 1, 2009 Report Share Posted July 1, 2009 nu kāā rēķini ka urls nevar but piemēram tā file_exists("waplet"); tāpēč vajag direktoriju, so tu vari mēģināt kaut vai tā file_exists("../avatars".$avatarsl){.... Link to comment Share on other sites More sharing options...
Mighty Posted July 1, 2009 Author Report Share Posted July 1, 2009 Jāāā, bet avatari ir prosta urļi, nevis noseivojās mapītē. Un $user['avatar']; izskatas apmeram ka http://gejiem.lv/gejs.jpg btw sor par gejiem, vnk tikko skatijos Bruno filmas treileri - geji tik nak prata :D Link to comment Share on other sites More sharing options...
Mighty Posted July 1, 2009 Author Report Share Posted July 1, 2009 Izdomāju. Vienkārši pieliku priekšā vēl vienu getimagesize $avatarins = ($user["avatar"]); if ($user["avatar"]) { //check if image exists if($img = @GetImageSize("$avatarins")) { $width =getimagesize($user["avatar"]); $maxwidth = 500; if ($width[0] > $maxwidth) print("<tr><td class=rofl4>".Avatar."</td><td class=rofl3 td align=left><img width=\"$maxwidth\" src=\"" . htmlspecialchars($user["avatar"]) . "\"></td></tr>\n"); else print("<tr><td class=rofl4>".Avatar."</td><td class=rofl3 td align=left><img src=\"" . htmlspecialchars($user["avatar"]) . "\"></td></tr>\n"); } else { } } Šitā :) Laikam diezgan primitīvi, bet pofig - strādā. Link to comment Share on other sites More sharing options...
J0ke Posted July 1, 2009 Report Share Posted July 1, 2009 kapēc pa lieko atkārtot kodu ja var īsāk ;) $avatarins = $user['avatar']; if ($avatarins) { $img = GetImageSize($avatarins) //check if image exists if ($img) { $maxwidth = 500; echo '<tr><td class="rofl4">Avatar</td><td class="rofl3" align="left"><img' . ($img[0] > $maxwidth ? ' width="' . $maxwidth . '"' : '') . ' src="' . htmlspecialchars($avatarins) . '" /></td></tr>'; } else { } } Link to comment Share on other sites More sharing options...
Mighty Posted July 2, 2009 Author Report Share Posted July 2, 2009 Aizmirsu paldies pateikt :) Paldies! Link to comment Share on other sites More sharing options...
Recommended Posts