drellout Posted May 5, 2010 Report Share Posted May 5, 2010 Es esmu izveidojies kautkadu diezgan nestradajoshu skriptu. Man vajadzigs, lai butu tā - ja lietotajam nav mape uploads/images/ vinja nosaukuma fails tad bilde iet $avatar_def = http://......, bet ja ir tad vinsh njem to failu... Man rada visus kas ir uplaadoti, rada tam kas tagad ir ielogojies, bet nerada citiem, vinji nez kapec grib njemt to bildi, bet vinjas nav. Rekur kods. $default_avatar = 'noavatar.png'; /* Username */ $avatar = $path= "".$req_user_info['username'].""; if ($avatar = $path= "".$req_user_info['username']."") echo "".$req_user_info['username'].""; else{ $avatar = $default_avatar; } echo "<b>Lietotajs: ".$req_user_info['username']."</b><br>"; echo "<b>Vards: ".$req_user_info['name']."</b><br>"; echo "<img align='right' class='photo_author' style='margin-top: -35px;' src='image/uploads/".$avatar."' width='120' height='100' alt='Bilde' />"; echo "<b>Vecums:</b>$age<br>"; echo "<b>Email:</b> ".$req_user_info['email']."<br>"; Palidzat ludzu izlabot šo skriptu, vai uzrakstat lūdzu jaunu. Paldies. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 5, 2010 Report Share Posted May 5, 2010 Neko nesapratu... =D Ideja: Ja lietotājam ir 'avatar' lauciņā kaut kas (datubāzē), tad ņemam to 'kaut kas', kas, īstenībā, ir links uz avataru, ja nav, tad ņemam - 'avatars/default.jpg'... =) Vismaz man tā liekas. =D Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 Neko nesapratu... =D Ideja: Ja lietotājam ir 'avatar' lauciņā kaut kas (datubāzē), tad ņemam to 'kaut kas', kas, īstenībā, ir links uz avataru, ja nav, tad ņemam - 'avatars/default.jpg'... =) Vismaz man tā liekas. =D Nu es esmu iesacejs, bet doma tada ja mape uploads ir lietotaja varda fails, tad vinsh tiek inkludots, ja nav tad avatar_def tiek Quote Link to comment Share on other sites More sharing options...
emsy Posted May 5, 2010 Report Share Posted May 5, 2010 (edited) if(files_exists("/uploads/avatars/".$taachaljaniks)) { print "<img src='/uploads/avatars/".$taachaljaniks."' />"; } elseif(!empty($taachaljabildesadresenodb)) { print "<img src='".$taachaljabildesadresenodb."' />"; } else { print "<img src='".$def_pic."' />"; } Edited May 5, 2010 by emsy Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 if(files_exists("/uploads/avatars/".$taachaljaniks)) { print "<img src='/uploads/avatars/".$taachaljaniks."' />"; } elseif(!empty($taachaljabildesadresenodb)) { print "<img src='".$taachaljabildesadresenodb."' />"; } else { print "<img src='".$def_pic."' />"; } Man vispar nav nekads db sakars Es satasiju taa - $req_user_info['username'] = $taachaljaniks; if(files_exists("/style/uploads/".$taachaljaniks)) { print "<img src='/style/uploads/".$taachaljaniks."' />"; } elseif(!empty($taachaljaniks)) { print "<img src='".$taachaljaniks."' />"; } else { print "<img src='".$def_pic."' />"; } Errors Fatal error: Call to undefined function files_exists() in C:\AppServ\www\userinfo.php on line 32 32 rinda if(files_exists("/style/uploads/".$taachaljaniks)) { Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 5, 2010 Report Share Posted May 5, 2010 Un tu izlasiiji, ko tev saka, tas errors? Fatal error: Call to undefined function files_exists() in C:\AppServ\www\userinfo.php on line 32 http://uk.php.net/file_exists Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 Es sataisiju šadi $avatar = '/style/uploads/".$req_user_info["username"]."'; if (file_exists($avatar)) { $avatar = $req_user_info["username"]; }elseif(!empty($avatar)) { $avatar = 'noavatar.png'; } ču čūč podaļše echo "<img align='right' class='photo_author' style='margin-top: -35px;' src='style/uploads/".$avatar."' width='120' height='100' alt='Bilde' />"; Visas bildes ir ka noavatar, palidzat, noradat manu kludu ludzu. Paldies. Quote Link to comment Share on other sites More sharing options...
m8t Posted May 5, 2010 Report Share Posted May 5, 2010 Vai to padomāji par to, ka bilde ar vārdu "niks" nekādīgi tu neparādīsi? Varbūt pieliec klāt kādu formātu, piemēram .jpg jeb .png? $avatar = '/style/uploads/'.$req_user_info["username"].'.png'; if (file_exists($avatar)) { $avatar = $req_user_info["username"]; }elseif(!empty($avatar)) { $avatar = 'noavatar.png'; } Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 Vai to padomāji par to, ka bilde ar vārdu "niks" nekādīgi tu neparādīsi? Varbūt pieliec klāt kādu formātu, piemēram .jpg jeb .png? $avatar = '/style/uploads/'.$req_user_info["username"].'.png'; if (file_exists($avatar)) { $avatar = $req_user_info["username"]; }elseif(!empty($avatar)) { $avatar = 'noavatar.png'; } Man uplaadojot bildes sanaca tik tizli. Uploado bildi ar nosaukumu tads kads useram, bez jpg. piem vnk m8t Quote Link to comment Share on other sites More sharing options...
bobsters Posted May 5, 2010 Report Share Posted May 5, 2010 pasties google.lv kā upload bildi ar visu extension :) Quote Link to comment Share on other sites More sharing options...
m8t Posted May 5, 2010 Report Share Posted May 5, 2010 Ja tev tā sanāca un tu nedalies ar skriptu - ko mums darīt? Starpcitu: http://tinyurl.com/2vxazor Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 pasties google.lv kā upload bildi ar visu extension :) Paldies, bilde tiek uplaadota ar formatiem. Vel joprojam ir problema http://paste.php.lv/65df2c92ba95c29950872847c71007fc?lang=php Vai ludzu kads varetu izlabot skriptu, lai tie cilveki kuriem ir bilde mapee style/uploads/ ar vinju niku nosaukumu radaas profilaa, ja nee tad $def_pic. Paldies Quote Link to comment Share on other sites More sharing options...
drellout Posted May 5, 2010 Author Report Share Posted May 5, 2010 Kāds palīdzēs lūdzu, kods ir augša atgādinu, vajag lai strādātu tāda shēma, nav db, tiem lietotajiem, kuriem ir bilde mapē styles/uploads ar viņu niku, lai rādas profilā $avatar, a tiem kuriem nav lai radās no-avatar.png. Paldies Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 5, 2010 Report Share Posted May 5, 2010 kuriem ir bilde mapē styles/uploads ar viņu niku, lai rādas profilā $avatar, a tiem kuriem nav lai radās no-avatar.png. izmanto http://lv.php.net/manual/en/function.file-exists.php un tikai nesaki ka visu vajag ar karotiiti .. tur uzrkstits gatvs kods ko tev , atliks tikai mazliet modificeet... 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.