halohalo
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
aramiyarkai
/
public_html
/
admin
/
Upload FileeE
HOME
<?php error_reporting (0); include "dbc.php"; page_protect(); ?> <?php $id=$_GET['id']; if($_GET['delete'] == 'd') { $id=$_GET['id']; $product_id=$_GET['product_id']; $group_proid=$_GET['group_proid']; list($s,$m,$l,$o)=mysql_fetch_row(mysql_query("select `small_image`, `medium_image`, `large_image`, `original_image` from multiple_image_tbl where id='$id'")); //echo $s; unlink($s); unlink($m); unlink($l); unlink($o); mysql_query("delete from multiple_image_tbl where id='$id'"); echo "<script>window.location.href='multiple_images.php?product_id=$product_id&group_proid=$group_proid&msg=2'</script>"; } function createThumb($ext,$temporaryFile,$filePath,$fileName,$newwidth) { if($newwidth == "250"){ $image_path ="images/watermark_250.png"; } elseif($newwidth == "500"){ $image_path ="images/watermark_500.png"; } elseif($newwidth == "750"){ $image_path ="images/watermark_750.png"; }else { $image_path ="images/watermark.png"; } $imageSize = getimagesize($temporaryFile); // Get the size of an image.It rerurns an array. $width = $imageSize[0]; // Get width of image in Pixels $height = $imageSize[1]; // Get height of image in pixels if($ext=="jpg" || $ext=="jpeg") { $src = imagecreatefromjpeg($temporaryFile); //returns a new created image from file or URL } else if($ext=="png") { $src = imagecreatefrompng($temporaryFile); } else if($ext=="gif") { $src = imagecreatefromgif($temporaryFile); } $newheight=($height/$width)*$newwidth; //Get the new height of image $temporaryBlackFile=imagecreatetruecolor($newwidth,$newheight); //returns a new true color black image with specified sizes imagecopyresampled($temporaryBlackFile,$src,0,0,0,0,$newwidth,$newheight,$width,$height); //Copy the new created image into black image and totally resize part of an image with resampling. $watermark = imagecreatefrompng($image_path); list($w_width, $w_height) = getimagesize($image_path); $pos_x = $newwidth - $w_width; $pos_y = $newheight - $w_height; imagecopy($temporaryBlackFile, $watermark, $pos_x, $pos_y, 0, 0, $newwidth, $newheight); $filename = $filePath.$newwidth.'/'.$fileName; if($ext=="jpg" || $ext=="jpeg" ) { imagejpeg($temporaryBlackFile,$filename,750); //copy the image into folder } else if($ext=="png") { imagepng($temporaryBlackFile,$filename,750); } else { imagegif($temporaryBlackFile,$filename,750); } imagedestroy($temporaryBlackFile); //cancel the Temporary file location return $filename; } if($_POST["submit"] == "Save"){ $count=count($_FILES['files']['name']); $filePath = "upload/"; $original = "upload/original/"; $product_id = $_POST['product_id']; $group_proid = $_POST['group_proid']; $maxp = $db->maxOfAll("id","multiple_image_tbl"); $maxp=$maxp+1; $multi_id="Multi".$maxp.""; for($i=0;$i<$count;$i++ ) { $temporaryFile = $_FILES['files']['tmp_name'][$i]; //get the Temporary location of file $temporaryName = $_FILES['files']['name'][$i]; //get the name of file. $extensionFile = strtolower(pathinfo($temporaryName, PATHINFO_EXTENSION)); $fileName = date("Y-m-d-h-i-s").rand().".".$extensionFile; $widthOfImages = array(250,500,750); //You can change dimension here. $a=1; foreach($widthOfImages as $newwidth) { $filename=createThumb($extensionFile,$temporaryFile,$filePath,$fileName,$newwidth); //Create a Image Thumbnails /* echo "<span class='pixels-$a'><img src='".$filename."' class='img img-responsive img-thumbnail'/></span></br>"; */ $a++; } move_uploaded_file($temporaryFile,$original.$fileName);//Move Original file from Temporary location to Original loca $files[$i] = $fileName ; } foreach($files as $file){ $sel_dup = mysql_query("select * from multiple_image_tbl where small_image='$file'"); if(mysql_num_rows($sel_dup)==0){ $ins_qurey = mysql_query("INSERT INTO `multiple_image_tbl`(`multi_id`, `product_id`, `small_image`, `medium_image`, `large_image`, `original_image`, `status`, `created_on`,`group_proid`) VALUES ('$multi_id','$product_id','upload/250/$file','upload/500/$file','upload/750/$file','upload/original/$file','Active',NOW(),'$group_proid')"); } echo "<script>window.location.href='multiple_images.php?group_proid=$group_proid&product_id=$product_id&msg=1';</script>"; } } ?> <?php include'header.php';?> <div class="main-bar"> <h3> <i class="icon-home"></i> Image Upload </h3> </div><!-- /.main-bar --> </header><!-- /.head --> </div><!-- /#top --> <?php include'admin_admin.php';?><!-- /#left --> <div id="content"> <div class="outer"> <div class="inner bg-light lter"> <style> .form-control.col-lg-6 { width: 50% !important; } </style> <div class="row"> <div class="col-lg-12"> <div class="box"> <header> <div class="row-fluid sortable"> <form action="" method="post" enctype="multipart/form-data" id="image-form" class="form-horizontal" > <fieldset> <div class="box span12"> <div class="box-header" data-original-title> <h2><i class="fa fa-edit"></i><span class="break"></span>Multiple Images Details</h2> <div class="box-icon"> <a href="#" class="btn-setting"><i class="halflings-icon wrench"></i></a> <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a> <a href="#" class="btn-close"><i class="halflings-icon remove"></i></a> </div> </div> <div class="box-content"> <div id="img_preview"></div> <?php $product_id = $_GET['product_id']; $group_proid = $_GET['group_proid']; $max = $db->maxOfAll("id","multiple_image_tbl"); $max=$max+1; $auto="Multi".$max.""; ?> <div class="control-group"> <label class="control-label">Product ID</label> <div class="controls"> <input class="input-xlarge" name="product_id" id="product_id" type="text" value="<?php echo $product_id; ?>" readonly> <input name="multi_id" id="multi_id" type="hidden" value="<?php echo $auto; ?>" > </div> </div> <div class="control-group"> <label class="control-label">Group Product ID</label> <div class="controls"> <input class="input-xlarge" name="group_proid" id="group_proid" type="text" value="<?php echo $group_proid; ?>" readonly> </div> </div> <div class="control-group"> <label class="control-label">Image</label> <div class="controls"> ( for ex : .jpg or .jpeg)<br> <input type="file" class="upload" name="files[]" id="files" multiple required /> </div> </div> <center> <div class="form-actions no-margin-bottom"> <input type="submit" id="submit-btn" name="submit" value="Save" class="btn btn-primary" /> </div> </center> </div> </div><!--/span--> </fieldset> </form> <div class="box span12"> <table id="dataTable" class="table table-bordered table-condensed table-hover table-striped"> <thead> <tr> <th>S.NO</th> <th>Product Name</th> <th>Title</th> <th>Image</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php $sno=1; $product_id = $_GET['product_id']; $group_proid = $_GET['group_proid']; $sel_employee = mysql_query("select * from multiple_image_tbl where group_proid='$group_proid' order by id desc "); while($rw_employee = mysql_fetch_object($sel_employee)){?> <tr> <td><?php echo $sno;?></td> <td class="center"><?php $sel_cat = mysql_query("select * from product_tbl where group_proid='$group_proid'"); $rw_cat = mysql_fetch_object($sel_cat); echo $rw_cat->product_name;?> </td> <td class="center"><?php echo $rw_cat->title;?></td> <td class="center"> <img src="<?php echo $rw_employee->small_image;?>" > </td> <?php /*?><td class="center"><?php $dept_id = $rw_employee->dept_id; $sel_depart = mysql_query("select * from department where dept_id='$dept_id'"); $rw_depart = mysql_fetch_object($sel_depart); echo $rw_depart->dept_name;?></td><?php */?> <td class="center"> <span class="label label-success">Active</span> </td> <td class="center"> <a class="btn btn-info" title="edit" href="update_img.php?id=<?php echo $rw_employee->id;?>&product_id=<?php echo $product_id;?>&group_proid=<?php echo $group_proid;?>"> <i class="fa fa-edit"></i> </a> <a class="btn btn-danger" title="delete" href="multiple_images.php?delete=d&id=<?php echo $rw_employee->id;?>&product_id=<?php echo $product_id;?>&group_proid=<?php echo $group_proid;?>" onclick="return confirm('Are you sure want to delete?')"> <i class="fa fa-trash"></i> </a> </td> </tr> <?php $sno++; } ?> </tbody> </table> </div> </div><!--/span--> </div><!--/row--> </div><!--/.fluid-container--> <!-- end: Content --> </div><!--/#content.span10--> </div><!--/fluid-row--> <div class="modal hide fade" id="myModal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h3>Settings</h3> </div> <div class="modal-body"> <p>Here settings can be configured...</p> </div> <div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">Close</a> <a href="#" class="btn btn-primary">Save changes</a> </div> </div> </div> </div> </div><!-- /.col-lg-12 --> </div><!-- /.row --> <!-- /.row --> <!-- /.row --> </div><!-- /.inner --> </div><!-- /.outer --> </div><!-- /#content --> <div id="right" class="bg-light lter"> <div class="alert alert-danger"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Warning!</strong> Best check yo self, you're not looking too good. </div> <!-- .well well-small --> <div class="well well-small dark"> <ul class="list-unstyled"> <li>Visitor <span class="inlinesparkline pull-right">1,4,4,7,5,9,10</span> </li> <li>Online Visitor <span class="dynamicsparkline pull-right">Loading..</span> </li> <li>Popularity <span class="dynamicbar pull-right">Loading..</span> </li> <li>New Users <span class="inlinebar pull-right">1,3,4,5,3,5</span> </li> </ul> </div><!-- /.well well-small --> <!-- .well well-small --> <div class="well well-small dark"> <button class="btn btn-block">Default</button> <button class="btn btn-primary btn-block">Primary</button> <button class="btn btn-info btn-block">Info</button> <button class="btn btn-success btn-block">Success</button> <button class="btn btn-danger btn-block">Danger</button> <button class="btn btn-warning btn-block">Warning</button> <button class="btn btn-inverse btn-block">Inverse</button> <button class="btn btn-metis-1 btn-block">btn-metis-1</button> <button class="btn btn-metis-2 btn-block">btn-metis-2</button> <button class="btn btn-metis-3 btn-block">btn-metis-3</button> <button class="btn btn-metis-4 btn-block">btn-metis-4</button> <button class="btn btn-metis-5 btn-block">btn-metis-5</button> <button class="btn btn-metis-6 btn-block">btn-metis-6</button> </div><!-- /.well well-small --> <!-- .well well-small --> <div class="well well-small dark"> <span>Default</span> <span class="pull-right"><small>20%</small> </span> <div class="progress xs"> <div class="progress-bar progress-bar-info" style="width: 20%"></div> </div> <span>Success</span> <span class="pull-right"><small>40%</small> </span> <div class="progress xs"> <div class="progress-bar progress-bar-success" style="width: 40%"></div> </div> <span>warning</span> <span class="pull-right"><small>60%</small> </span> <div class="progress xs"> <div class="progress-bar progress-bar-warning" style="width: 60%"></div> </div> <span>Danger</span> <span class="pull-right"><small>80%</small> </span> <div class="progress xs"> <div class="progress-bar progress-bar-danger" style="width: 80%"></div> </div> </div> </div><!-- /#right --> </div><!-- /#wrap --> <?php include'footer.php';?>