Current File : /home/inlingua/www/sensoriumpsychologists.com/admin/edit_gallery.php |
<?php
include_once('include/include.script.php');
include_once('include/navigation.php');
include_once('../classes/config.php');
$id=$_GET['id'];
$result=$query->select_where('shristi_gallery','id',$id);
$rows=$result->fetch_assoc();
$picture=$rows['file'];
ini_set("error_reporting", 1);
function compress($source, $destination, $quality) {
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source);
imagejpeg($image, $destination, $quality);
return $destination;
}
extract($_REQUEST);
if(isset($submit)){
/*image uplaoding*/
$newpicture=$_FILES['exterior_pic1']['name'];
if($newpicture) {
$prefix = rand(00000,10000);
$file_name = $prefix."_".date("YmdHis")."_".$newpicture;
$file_upload_pic1 = str_replace(" ", "_", $file_name);
$destination_url = "../uploads/gallery/".$file_upload_pic1;
$source_img = $_FILES["exterior_pic1"]["tmp_name"];
$fianl_file = compress($source_img, $destination_url, 50);
if($fianl_file){
//if(move_uploaded_file($_FILES['exterior_pic1']['tmp_name'],"../uploads/gallery/".str_replace(" ", "_", $file_name))){
//$file_upload_img = str_replace(" ", "_", $file_name);
unlink('../uploads/gallery/'.$picture);
$date_time=date('Y-m-d');
$data=array(
'title' => $_POST['title'],
'file' => $file_upload_pic1,
'update_date' => $date_time,
);
$update=$query->qry_update('shristi_gallery','id',$data,$id);
if($update){$message->success_updated();
//die;
echo "<meta http-equiv=\"refresh\" content=\"1;URL=list_gallery.php\">";
}else{$error->error();}}
}else{
$data1=array(
'title' => $_POST['title'],
'file' => $file_upload_img,
'update_date' => $date_time,
);
$update1=$query->qry_update('shristi_gallery','id',$data1,$id);
if($update1){$message->success_updated();
echo "<meta http-equiv=\"refresh\" content=\"1;URL=list_gallery.php\">";
}else{$error->error();}
}
}
?>
<div id="main">
<div class="container-fluid">
<div class="page-header">
<div class="pull-left">
<h3><i class="icon-ok"></i>Edit Image</h3>
</div>
<div class="pull-right">
<ul class="stats">
<li class='lightred'>
<i class="icon-calendar"></i>
<div class="details">
<span class="big">February 22, 2013</span>
<span>Wednesday, 13:56</span>
</div>
</li>
</ul>
</div>
</div>
<div class="breadcrumbs">
<ul>
<li>
<a href="home.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li>
<a href="">Edit Image</a>
</li>
</ul>
<div class="close-bread">
<a href="#"><i class="icon-remove"></i></a>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="box box-bordered box-color">
<div class="box-title">
<h3><i class="icon-th-list"></i>Edit Image</h3>
</div>
<div class="box-content nopadding">
<form method="POST" class='form-horizontal form-column form-bordered form-validate' id="bb" enctype="multipart/form-data">
<div class="span12" style="background-color:#848484;">
<h4 style="color:#fff; margin-left:50px;">Study Image</h4></div>
<div class="span12">
<div class="control-group">
<label for="textfield" class="control-label">Title</label>
<div class="controls">
<input type="text" name="title" id="textfield1" placeholder="Title" class="input-xlarge span10" data-rule-required="true" data-rule-minlength="3" value="<?php echo $rows['title'];?>">
</div>
</div>
<div class="control-group">
<label for="textfield" class="control-label">File Upload</label>
<div class="controls">
<a target="_blank" href="../uploads/gallery/<?php echo $rows['file'];?>" downalod>Downalod</a>
</div>
</div>
<div class="control-group">
<label for="textfield" class="control-label">File Upload</label>
<div class="controls">
<input type="file" name="exterior_pic1" class="input-xlarge">
</div>
</div>
</div>
<div class="span12" style="background-color:#368ee0; padding:5px 0px 5px 20px;">
<button type="submit" name="submit" value="Submit" class="btn btn-primary">Update</button>
<button type="button" class="btn" id="something">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>