Niko222 Posted January 31, 2012 Report Share Posted January 31, 2012 Nezinu vai kods ir pareizi uztaisīts bet kas varētu būt pa vainu man bilde nelādējas un neparādas kur viņai vaidzētu būt. <?php session_start(); include('inc/config.php'); include('inc/functions.php'); if(isset($_SESSION['user_id'])){ $change=""; $abc=""; if($_FILES['file']){ define ("MAX_SIZE","5000"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "psd")) { $change='<div class="msgdiv">Kļūda! Nezināms bildes formāts</div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">Jūs pārsniedzāt bildes izmēra limitu (MB)</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=150; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=50; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); $orgwidth=$width; $orgheight=($height/$width)*$orgwidth; $org=imagecreatetruecolor($orgwidth,$orgheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); imagecopyresampled($org,$src,0,0,0,0,$orgwidth,$orgheight,$width,$height); $time = time(); $filename = "images/thumb_".$time."_". $_FILES['file']['name']; $profile_photo_url = $time."_". $_FILES['file']['name']; $filename1 = "images/small_".$time."_". $_FILES['file']['name']; $orginal = "images/".$time."_". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagejpeg($org,$orginal,100); function watermarkImage($location) { $imagesource = $location; $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if (!$image) die(); $watermark = @imagecreatefrompng(K_small_logo_watermark.png'); $imagewidth = imagesx($image); $imageheight = imagesy($image); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $size = getimagesize($location); $differenceX = $imagewidth - $watermarkwidth; $placementX = round($differenceX / 2); $y_pos = $size[1] - $watermarkheight - 10; imagecopy($image, $watermark, $placementX, $y_pos, 0, 0, $watermarkwidth, $watermarkheight); imagejpeg($image, $location); } //Izsauc Funkciju watermarkImage($orginal); mysql_query("UPDATE lietotaji SET profile_photo='".$profile_photo_url."' WHERE user_id='".intval($_SESSION['user_id'])."'"); mysql_query("DELETE FROM rate WHERE id='profile".intval($_SESSION['user_id'])."'"); $suc='Bilde augšupielādēta veiksmīgi!'; echo '<script type="text/javascript"> var data = "'.$suc.'"; parent.myCallBackFunction(data); </script>'; imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); imagedestroy($org); } } } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> .bx { background-color: #F3F3F3; border: 1px solid #CCC; border-bottom-left-radius: 7px 7px; border-bottom-right-radius: 7px 7px; border-top-left-radius: 7px 7px; border-top-right-radius: 7px 7px; margin-bottom: 10px; padding: 7px 10px; position: relative; zoom: 1; } </style> <div class="bx"> <center> <b><font color="red">Profila bildē ir jābūt redzamam tev!</font></b><br/> <font color="red">Tev ir jābūt skaidri saskatāmam un atpazīstamam.</font><br/> </center> <br/> <center> <div style="width: 470px; background: #eee; border: 1px solid #ccc;"> <form action="change_foto.php" enctype="multipart/form-data" method="post" target="iframe"> <b>Bilde: </b><input size="10" name="file" type="file" value="Izvēlēties"/><br /> (Ieteicams .jpg bildes formāts)<br/><br/> <input type="submit" value="Augšupielādet" /> <iframe name="iframe" style="display:none;"></iframe> </form> </div> </center> <script> function myCallBackFunction(data) { //put your code here alert(data); } </script> <?php } else { error("Lai mainītu bildi, jums ir jāautorizējas!"); }?> Link to comment Share on other sites More sharing options...
aika Posted February 1, 2012 Report Share Posted February 1, 2012 forums pats pasaka priekšā!: if (!$image) die(); $watermark = @imagecreatefrompng(K_small_logo_watermark.png'); $imagewidth = imagesx($image); pirms K ieliec ' un vispār - skaties kļūdas! Link to comment Share on other sites More sharing options...
Niko222 Posted February 1, 2012 Author Report Share Posted February 1, 2012 Tā jau ir bilde kas iet uz bildes virsū piemēram takā logotips firmas. Tikuntā nejiet . Link to comment Share on other sites More sharing options...
daGrevis Posted February 1, 2012 Report Share Posted February 1, 2012 Tev ir sintakses kļūda. Tas ir pirmais, kas tev ir jānovērš! Link to comment Share on other sites More sharing options...
Kavacky Posted February 1, 2012 Report Share Posted February 1, 2012 Link to comment Share on other sites More sharing options...
Niko222 Posted February 1, 2012 Author Report Share Posted February 1, 2012 Tev ir sintakses kļūda. Tas ir pirmais, kas tev ir jānovērš! Darīts noversū bez izmaiņām. Link to comment Share on other sites More sharing options...
daGrevis Posted February 1, 2012 Report Share Posted February 1, 2012 Tālāk ir jādomā kāpēc skripts neiet. Pa mazām daļiņām ej cauri visam un meklē kāpēc nenotiek tas, kam vajadzētu notikt. Link to comment Share on other sites More sharing options...
Niko222 Posted February 1, 2012 Author Report Share Posted February 1, 2012 Sākumā bilde lādējas bet neaiziet uz norādīto vietu kur viņai jāaiziet būtu jāaiziet.. Link to comment Share on other sites More sharing options...
daGrevis Posted February 1, 2012 Report Share Posted February 1, 2012 Posms #1: success! Tālāk domā kāpēc notiek tas: > [..] bet neaiziet uz norādīto vietu kur viņai jāaiziet būtu jāaiziet.. Vai arī tu domā, ka kāds no šejieniešiem ņemsies ar tavu 162 rindiņas garo HTML/CSS/JavaScript/PHP/SQL "koda" blāķi? (: Link to comment Share on other sites More sharing options...
Niko222 Posted February 1, 2012 Author Report Share Posted February 1, 2012 Nevaig man lai ņemās ar visu bļāki :D . Vienkarši gribu zināt kur ir problēmas lai varu novērst. Link to comment Share on other sites More sharing options...
daGrevis Posted February 2, 2012 Report Share Posted February 2, 2012 Tad meklē! Slēdzu. Link to comment Share on other sites More sharing options...
Recommended Posts