[S]Bu kısımda elinizin altında olması gereken ufak kod parçalarına ve kod kitlelerine linklere yer vereceğiz.
bu kodlar sizlerin en çok oy verdiği uygun konulardan oluşacak.
hello world
php kodu:
<?
echo "Hello World!";
?>
Resim boyutlama:
<?
function resize($resim,$max_en=150,$max_boy=100){
ob_start();
# Yeni boyutları hesaplıyoruz
$boyut = getimagesize($resim);
$en = $boyut[0];
$boy = $boyut[1];
$x_oran = $max_en / $en;
$y_oran = $max_boy / $boy;
if (($en <= $max_en) and ($boy <= $max_boy))
{
$son_en = $en;
$son_boy = $boy;
}
else
if (($x_oran * $boy) < $max_boy)
{
$son_en = $max_en;
$son_boy = ceil($x_oran * $boy);
}
else
{
$son_en = ceil($y_oran * $en);
$son_boy = $max_boy;
}
$eski = imagecreatefromjpeg($resim);
$yeni = imagecreate($son_en,$son_boy);
imagecopyresized($yeni,$eski,0,0,0,0,
$son_en,$son_boy,$en,$boy);
imagejpeg($yeni,null,-1);
$icerik = ob_get_contents();
ob_end_clean();
imagedestroy($eski);
imagedestroy($yeni);
return $icerik;
}
$dizin = "Image"; # Resmın olusturulucagı dızın
if (isset($resim)){
$icerik = resize($resim,$max_en,$max_boy);
$dosya = fopen ($dizin."/".$resim_name,"w+");
fwrite($dosya,$icerik);
fclose($dosya);
echo "<img src=\"$dizin/$resim_name\">";
}
else
{
?>
<html>
<head>
<meta http-equiv="Content-Language" content="tr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<title>Yeniden Ölçülendir</title>
</head>
<body style="font-family: Tahoma; font-size: 12px">
<form method="POST" enctype="multipart/form-data" action="resize.php">
En:<br>
<input type="text" name="max_en" size="10" value="150"><br>
Boy:<br>
<input type="text" name="max_boy" size="10" value="100"><br>
Resim:<br>
<input type="file" name="resim" size="20"><br>
<br>
<input type="submit" value="Gönder" name="gonder"></p>
</form>
</body>
</html>
<?
}
?>
Dosya içeriğini değişkene aktarma:
<?
$fp=fopen($dosya,'r');
$canimdoyaicerigim="";
while (!feof($fp)){
$canimdoyaicerigim.=fgets($fp,4096);
}
?>
şimdilik bu kadar arkalaşlar[/S]


LinkBack URL
About LinkBacks



Alıntı
