Kodlar çalışıyor sadece resmin yolunu yazdırmak istiyorum. Birde fazla kod kalabalığı var gibi bu işin bu kadar uzun olacağını sanmıyorum ama araya araya böyle bişey buldum..resim_ekle.php sayfam
<?php
session_start();
ob_start();
include("ayar.php");
if($_SESSION["user"] != $user){
echo "<script> alert('Admin Girişi Yapınız!');
window.location='admingirisi.php';
</script>";
}
require_once 'ust.php';
include("uploader.php");
?>
<table width="1010" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#FFFFFF">
<td align="right" valign="middle"><span class="bulsayfa">Bulunduğunuz Sayfa: Program Ekle </span></td>
</tr>
</table>
<table width="1010" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><h2>Resim Ekle</h2>
<?php
if (!empty($_GET) && empty($_GET['x'])) {
$message=$_GET['message'];
echo $message;
if ($message=="Resim Dosyası Yüklendi.") {
} else { echo "Hata Olustu."; }
} else {
$eid = $_GET['x'];
?>
<strong>Resmi Seçiniz (izin verilen dosya uzantıları .jpg , .gif , .png</strong>
<table><tr><td>
</strong></p>
<form action="Resim_Ekle.php" enctype="multipart/form-data" id="upload" method="post">
<p><input id="userfile" name="userfile" size="45" type="file" />
<input name="id" type="hidden"/>
<input name="upload" type="submit" value="Dosya Yukle" />
</p>
</form>
</td></tr></table></td>
</tr>
</table>
</td>
</tr>
</table>
<? } ?>uploader.php sayfam<?
$allow_file_deletion = true; // Set this to true or false
$file_extensions = array('.gif,.jpg,.png'); // Separate each with a comma
$maximum_file_size = 5120000000; // In bytes
$message = ""; // Leave this blank
$mime_types = array('image/gif','image/jpeg','image/pjpeg');
// To distinguish the MIME types, attempt to upload a file, then copy/paste the MIME type from there
$set_chmod = 0; // Leave this at 0
$upload_directory = "../urun_resimleri/";
$upload_uri = $uri_dir."urun_resimleri/";
$uri_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$uri_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
// End options; don't edit past this unless you know what you're doing
if($allow_file_deletion == true) $status = "enabled";
else $status = "disabled";
if($_REQUEST[del] && $allow_file_deletion) {
$resource = fopen("upload_log.txt","a");
fwrite($resource,date("F d, Y / h:i:sa")." - ".$_REQUEST[del]." Deleted by ".$_SERVER[REMOTE_ADDR]."\n");
fclose($resource);
if(strpos($_REQUEST[del],"/.") > 0);
elseif(strpos($_REQUEST[del],$upload_directory) === false);
elseif(substr($_REQUEST[del],0,6) == $upload_directory) {
unlink($_REQUEST[del]);
echo "<script>window.location.href=\"$uri_this?message=File has been deleted.\"</script>";
}
}
elseif($_FILES['userfile']) {
$resource = fopen("upload_log.txt","a");
fwrite($resource,date("F d, Y / h:i:sa")." - ".$_FILES['userfile']['name']." "
.$_FILES['userfile']['type']." Uploaded by ".$_SERVER[REMOTE_ADDR]."\n");
fclose($resource);
$file_type = $_FILES['userfile']['type'];
$file_name = $_FILES['userfile']['name'];
$file_ext = substr($file_name, -4);
//$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
@chmod($upload_uri."".$file_name, 0755);
if($_FILES['userfile']['size'] > $maximum_file_size) {
$message = "ERROR: File size cannot be over ".$maximum_file_size." bytes.";
}
elseif($file_name == "") $message = "ERROR: Please select a file to upload.";
elseif(!preg_match("/^[A-Z0-9_.\- ]+$/i",$file_name)) $message = "ERROR: Your file name contains invalid characters.";
elseif ($a!=$b)
$message = "ERROR: $file_ext";
else $message = upload_file($upload_directory, $upload_uri);
echo "<script>window.location.href=\"$uri_this?message=$message\"</script>";
}
elseif(!$_FILES['userfile']);
else $message = "ERROR: Invalid file specified.";
$handle = opendir($upload_directory);
$filelist = "";
// $file = sort($file);
while($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= " <tr>
<td style=\"background: #fff; color: #000; text-align: left; width: 50%\"><a href=\"$upload_directory$file\" title=\"$file (".filesize($upload_directory."".$file)." bytes)\">".$file."</a> (".filesize($upload_directory."".$file)." bytes)</td>";
if($allow_file_deletion)
$filelist .= "
<td style=\"background: #fff; color: #000; text-align: right; width: 50%\"><a href=\"?del=$upload_directory".urlencode($file)."\" title=\"Delete File\">Delete File</a></td>";
else
$filelist .= "
<td style=\"background: #fff; color: #000; text-align: right; width: 50%\"><del><strong>Delete File</strong></del></td>";
$filelist .= "
</tr>
<tr>
<td colspan=\"2\" style=\"background: #eee; color: #000; text-align: left; text-indent: 20px\">Uploaded <strong>".date("Y-F-d / h:ia", filemtime($upload_directory.$file))."</strong></td>";
$filelist .="
</tr>
";
}
}
function upload_file($upload_directory, $upload_uri) {
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_name = str_replace(" ","_",$file_name);
$file_name = str_replace(".PNG",".png",$file_name);
$file_name = str_replace(".GIF",".gif",$file_name);
$file_name = str_replace(".JPG",".jpg",$file_name);
$file_name = str_replace(".TXT",".txt",$file_name);
$file_path = $upload_directory.date("Y-m-d_h_").$file_name;
$temporary = $_FILES['userfile']['tmp_name'];
if($file_name == "") {
$message = "ERROR: Invalid file name.";
return $message;
}
$result = move_uploaded_file($temporary, $file_path);
if(!chmod($file_path,0777))
$message = "ERROR: A folder to place the files was not found.";
else $message = ($result)?"Resim Dosyası Yüklendi.&id=".$_REQUEST["id"]."&file_path=".date("Y-m-d_h_").$file_name : "An error has occurred.";
$file_path=date("Y-m-d_h_").$file_name;
include_once("thumbresize.php");
$thumbbb=new thumbnail("../urun_resimleri/".$file_path);
$thumbbb->size_width(200);
$thumbbb->size_height(200);
$thumbbb->jpeg_quality(100);
$thumbbb->save("../urun_resimleri/".$file_path);
return $message;
}
?>thumbresize.php sayfam<?
class thumbnail
{
var $img;
function thumbnail($imgfile)
{
//detect image format
$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
$this->img["format"]=strtoupper($this->img["format"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
$this->img["format"]="JPEG";
$this->img["src"] = ImageCreateFromJPEG ($imgfile);
} elseif ($this->img["format"]=="PNG") {
//PNG
$this->img["format"]="PNG";
$this->img["src"] = ImageCreateFromPNG ($imgfile);
} elseif ($this->img["format"]=="GIF") {
//GIF
$this->img["format"]="GIF";
$this->img["src"] = ImageCreateFromGIF ($imgfile);
} elseif ($this->img["format"]=="WBMP") {
//WBMP
$this->img["format"]="WBMP";
$this->img["src"] = ImageCreateFromWBMP ($imgfile);
} else {
//DEFAULT
echo "Not Supported File";
exit();
}
@$this->img["lebar"] = imagesx($this->img["src"]);
@$this->img["tinggi"] = imagesy($this->img["src"]);
//default quality jpeg
$this->img["quality"]=95;
}
function size_height($size=100)
{
//height
$this->img["tinggi_thumb"]=$size;
@$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
}
function size_width($size=100)
{
//width
$this->img["lebar_thumb"]=$size;
@$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
}
function size_auto($size=100)
{
//size
if ($this->img["lebar"]>=$this->img["tinggi"]) {
$this->img["lebar_thumb"]=$size;
@$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
} else {
$this->img["tinggi_thumb"]=$size;
@$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
}
}
function jpeg_quality($quality=100)
{
//jpeg quality
$this->img["quality"]=$quality;
}
function show()
{
//show thumb
@Header("Content-Type: image/".$this->img["format"]);
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["des"],"",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["des"]);
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["des"]);
} elseif ($this->img["format"]=="WBMP") {
//WBMP
imageWBMP($this->img["des"]);
}
}
function save($save)
{
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["des"],"$save",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["des"],"$save");
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["des"],"$save");
} elseif ($this->img["format"]=="WBMP") {
//WBMP
imageWBMP($this->img["des"],"$save");
}
}
}
?>