Ysm adlı üyeden alıntı: mesajı görüntüle
sitemde kullandığım script php ve benim php bilgim çok zayıf ve şöyle bir sorunum var resim.jpg şeklinde bir resim yüklediğimde bu resmi 1357044666.jpg şeklinde isimlendirerek uploads klasörüne atıyor ve bu site için çok da iyi bir şey olmuyor bunu nasıl kapatabilirim acaba?

Kullanılan kodlar. pek fazla php bilgim yoktur ama anladığım kadarıyla aşağıda ki 2 dosyadan birinin içinde.

<?php include('header.php');

$edit = $_GET['id'];

$sqlcovers = mysql_query("SELECT * FROM covers WHERE id='$edit'") or die (mysql_error());
$coverrow = mysql_fetch_array($sqlcovers);
$cid = $coverrow['catid'];
$fid = $coverrow['featured'];
if ($fid==1){
	$ftxt='Yes';
	$fnum='1';
}else{
	$ftxt='No';
	$fnum='0';
}

$delimage = $coverrow['picture'];


error_reporting(E_ALL ^ E_NOTICE);

$q=mysql_query("select * from watermark where id=1");
$s=mysql_fetch_assoc($q);

$wmarkit = $s['watermark'];

if($wmarkit==1){
$image_path = "../images/watermark.png";
}else{
$image_path = "../images/no_watermark.png";	
}
	
	

function watermark_image($oldimage_name, $new_image_name){
    global $image_path;
    list($owidth,$oheight) = getimagesize($oldimage_name);
    $width = 850;
	$height = 315;    
    $im = imagecreatetruecolor($width, $height);
    $img_src = imagecreatefromjpeg($oldimage_name);
    imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
    $watermark = imagecreatefrompng($image_path);
    list($w_width, $w_height) = getimagesize($image_path);        
    $pos_x = $width - $w_width; 
    $pos_y = $height - $w_height;
    imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
    imagejpeg($im, $new_image_name, 100);
    imagedestroy($im);
    unlink($oldimage_name);
    return true;
}


$finale_image= "";
if(isset($_POST['createmark']) and $_POST['createmark']  == "Submit"){

    $path = "../uploads/";
    $valid_formats = array("jpg",  "bmp","jpeg");
	$name = $_FILES['imgfile']['name'];
	if(strlen($name))
{
   list($txt, $ext) = explode(".", $name);
   if(in_array($ext,$valid_formats)&& $_FILES['imgfile']['size'] <= 1024*1024)
	{
    $upload_status = move_uploaded_file($_FILES['imgfile']['tmp_name'], $path.$_FILES['imgfile']['name']);
    if($upload_status){
        $new_name = $path.time().".jpg";
        if(watermark_image($path.$_FILES['imgfile']['name'], $new_name))
                $finale_image = $new_name;
                
    }
////////ADD INFO///////

$sname = explode("/", $new_name);
$s_name = $sname[2];



$qu= mysql_query("UPDATE covers SET picture='$s_name' WHERE id='$edit'");

//DELETE THE OLD IMAGE
unlink("../uploads/$delimage");
////////ADD INFO///////	
	}
	else
	$msg="File size Max 1 MB or Invalid file format. Supports .jpg and .bmp";
	}
}
?>

<div class="maintitle">Change Cover Image</div>
<div class="box">
<div class="inbox">
<div class="info-box">Only upload  850 x 315 sized JPG, JPEG files. Warning: your old image will be replaced and deleted.</div>
        <form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" >
        		
                <!--#-->
                <label class="artlbl">Image</label>
          <div class="formdiv">
            <input type="file" name="imgfile" id="imgfile"/><br />
                </div>
                <div class="formdiv">
                <div class="sbutton">
                <input type="submit" name="createmark" id="createmark" value="Submit" />
               </div>
               </div>
               <div class="space">&nbsp;</div>
            <?php
                if(!empty($finale_image))
                    echo '<br/><center><img src="'.$finale_image.'" /></center>';
				else
				    echo '<h3>'.$msg.'</h3>';
            ?>
        </form>
</div>
</div><!--box-->
<?php include('footer.php');?>

<?php include('header.php');

error_reporting(E_ALL ^ E_NOTICE);

$q=mysql_query("select * from watermark where id=1");
$s=mysql_fetch_assoc($q);

$wmarkit = $s['watermark'];

if($wmarkit==1){
$image_path = "../images/watermark.png";
}else{
$image_path = "../images/no_watermark.png";	
}
	
	

function watermark_image($oldimage_name, $new_image_name){
    global $image_path;
    list($owidth,$oheight) = getimagesize($oldimage_name);
    $width = 850;
	$height = 315;    
    $im = imagecreatetruecolor($width, $height);
    $img_src = imagecreatefromjpeg($oldimage_name);
    imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
    $watermark = imagecreatefrompng($image_path);
    list($w_width, $w_height) = getimagesize($image_path);        
    $pos_x = $width - $w_width; 
    $pos_y = $height - $w_height;
    imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
    imagejpeg($im, $new_image_name, 100);
    imagedestroy($im);
    unlink($oldimage_name);
    return true;
}


$finale_image= "";
if(isset($_POST['createmark']) and $_POST['createmark']  == "Submit"){

    $path = "../uploads/";
    $valid_formats = array("jpg",  "bmp","jpeg");
	$name = $_FILES['imgfile']['name'];
	if(strlen($name))
{
   list($txt, $ext) = explode(".", $name);
   if(in_array($ext,$valid_formats)&& $_FILES['imgfile']['size'] <= 1024*1024)
	{
    $upload_status = move_uploaded_file($_FILES['imgfile']['tmp_name'], $path.$_FILES['imgfile']['name']);
    if($upload_status){
        $new_name = $path.time().".jpg";
        if(watermark_image($path.$_FILES['imgfile']['name'], $new_name))
                $finale_image = $new_name;
                
    }
////////ADD INFO///////

$sname = explode("/", $new_name);
$s_name = $sname[2];
$title = mysql_real_escape_string($_POST['title']);
$tags = mysql_real_escape_string($_POST['tags']);
$catid = mysql_real_escape_string($_POST['categories']);
$featured = mysql_real_escape_string($_POST['featured']);
$pdate = date("F j, Y");


$qu = "INSERT INTO covers(catid,title,tags,picture,date,featured)VALUES ('".$catid."','".$title."','".$tags."','".$s_name."','".$pdate."','".$featured."')";
mysql_query($qu) or die (mysql_error());

////////ADD INFO///////	
	}
	else
	$msg="File size Max 1 MB or Invalid file format. Supports .jpg and .bmp";
	}
}
?>

<div class="maintitle">Add New Cover</div>
<div class="box">
<div class="inbox">
<div class="info-box">Only upload  850 x 315 sized JPG, JPEG files.</div>
        <form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" >
        		<label class="artlbl">Category</label>
				<div class="formdiv">
				<select tabindex="2" name="categories" id="categories">
<option value="">----- Select Category -----</option>
<?php
$cat = mysql_query("SELECT * FROM category ORDER BY catname") or die (mysql_error());
while ($catrow = mysql_fetch_array($cat)){?>
?>
<option value="<?php echo $catrow['id'];?>"><?php echo $catrow['catname'];?></option>
<?php }?> 
</select>
				</div>
                
<label class="artlbl">Cover Name</label>
				<div class="formdiv">
				<input type="text" name="title" value=""/>
				</div>

<label class="artlbl">Tags</label>
				<div class="formdiv">
				<input type="text" name="tags" value=""/>
				</div>
<label class="artlbl">Make This a Featured Cover:</label>
				<div class="formdiv">
				<select name="featured">                
                <option value="0">No</option>
                <option value="1">Yes</option>
                </select>
				</div>                
                
                <!--#-->
                <label class="artlbl">Image</label>
                <div class="formdiv">
                <input type="file" name="imgfile" id="imgfile"/><br />
                </div>
                <div class="formdiv">
                <div class="sbutton">
                <input type="submit" name="createmark" id="createmark" value="Submit" />
               </div>
               </div>
               <div class="space">&nbsp;</div>
            <?php
                if(!empty($finale_image))
                    echo '<br/><center><img src="'.$finale_image.'" /></center>';
				else
				    echo '<h3>'.$msg.'</h3>';
            ?>
        </form>
</div>
</div><!--box-->
<?php include('footer.php');?>
Resimlerin random sayıyla klasöre yüklenmesi daha iyi ya. Millet onu yapmaya çalışıyor.
Misal olarak aynı resim adında bir resim yükledin o zaman ne yapıcaksın ? Resmin üzerine yazacak ya.