Sunday, 13 March 2016
Thursday, 10 March 2016
add smooth scrolling using jquery in menu
Hello Here example Add Smooth scroll menu in menu
simple add this js in your page. check it it. it working file
but you need to add jquery.easing.min.js in your header after jquery
jQuery(function() {
jQuery('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
simple add this js in your page. check it it. it working file
but you need to add jquery.easing.min.js in your header after jquery
jQuery(function() {
jQuery('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
Tuesday, 16 February 2016
image upload with compress image and add text into image in using php
Hello Here Example Image compress and add text into image
<?php
function compress_image($source_url, $destination_url, $quality) {
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
// Set Path to Font File
$color = imagecolorallocate($image, 255, 255, 255);
//x-coordinate of the upper left corner.
$xPos = 600;
//y-coordinate of the upper left corner.
$yPos = 200;
//Writting the picture
imagestring($image,5,$xPos,$yPos,"Add Your Text Here",$color);
imagejpeg($image, $destination_url, $quality);
return $destination_url;
}
if(isset($_POST['submit'])){
$tempPath = $_FILES['upload']['tmp_name'];
$mypath = "compress";
if(!is_dir($mypath)){
mkdir($mypath);
}
$filename = $_FILES['upload']['name'];
$destination = $mypath."/".$filename;
$destination = compress_image($tempPath,$destination,90);
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="upload"/>
<input type="submit" name="submit" value="upload"/>
</form>
<?php
function compress_image($source_url, $destination_url, $quality) {
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
// Set Path to Font File
$color = imagecolorallocate($image, 255, 255, 255);
//x-coordinate of the upper left corner.
$xPos = 600;
//y-coordinate of the upper left corner.
$yPos = 200;
//Writting the picture
imagestring($image,5,$xPos,$yPos,"Add Your Text Here",$color);
imagejpeg($image, $destination_url, $quality);
return $destination_url;
}
if(isset($_POST['submit'])){
$tempPath = $_FILES['upload']['tmp_name'];
$mypath = "compress";
if(!is_dir($mypath)){
mkdir($mypath);
}
$filename = $_FILES['upload']['name'];
$destination = $mypath."/".$filename;
$destination = compress_image($tempPath,$destination,90);
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="upload"/>
<input type="submit" name="submit" value="upload"/>
</form>
Friday, 5 February 2016
How to pass variables via PHP CURL
How to pass variables via PHP CURL
$message="Thank you";
$phone = 123456789;
$url = 'http://example.com';
$fields = array('phone'=>$phone,'source'=>'test','message'=>$message);
$fields_string='';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
$message="Thank you";
$phone = 123456789;
$url = 'http://example.com';
$fields = array('phone'=>$phone,'source'=>'test','message'=>$message);
$fields_string='';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
Saturday, 30 January 2016
Insert Csv File Data in Mysql using Php with Validation
Insert Csv File Data in Mysql using Php with Validation Full Example
Sample Csv File Test.csv
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script type="application/javascript">
$(document).ready(function(e) {
$('#pincodeList').validate({
rules: {
Csv: {
required: true,
extension: "xls|csv"
}
},
messages: {
Csv: {
extension: 'Please upload a csv file!'
}
}
});
});
</script>
<?php
include('connect.php');
if($_POST['submit']){
$csv_file = $_FILES['Csv']['name'];
$tmpFilePath =$_FILES['Csv']['tmp_name'];
$newFilePath="pincodeUpload/";
$mypath = "pincodeUpload/".$csv_file;
move_uploaded_file($tmpFilePath, $mypath);
if ( ! is_dir($newFilePath)) {
mkdir($newFilePath);
}
$csv_file =$mypath;
if (($handle = fopen($csv_file, "r")) !== FALSE) {
fgetcsv($handle);
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$col[$c] = $data[$c];
}
$col1 = $col[0];
// SQL Query to insert data into DataBase
$query = "INSERT INTO pincode(Pincode) VALUES('$col1')";
$s = mysql_query($query);
}
fclose($handle);
}
}
?>
<form id="pincodeList" name="pincodeList" method="post" enctype="multipart/form-data">
<div class="row">
<div class="co-md-3 col-sm-6">
<input type="file" name="Csv" >
</div>
<div class="co-md-3 col-sm-6">
<input class="btn btn-success" type="submit" name="submit" value="Upload Csv"/>
</div>
</div>
</form>
Sample Csv File Test.csv
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script type="application/javascript">
$(document).ready(function(e) {
$('#pincodeList').validate({
rules: {
Csv: {
required: true,
extension: "xls|csv"
}
},
messages: {
Csv: {
extension: 'Please upload a csv file!'
}
}
});
});
</script>
<?php
include('connect.php');
if($_POST['submit']){
$csv_file = $_FILES['Csv']['name'];
$tmpFilePath =$_FILES['Csv']['tmp_name'];
$newFilePath="pincodeUpload/";
$mypath = "pincodeUpload/".$csv_file;
move_uploaded_file($tmpFilePath, $mypath);
if ( ! is_dir($newFilePath)) {
mkdir($newFilePath);
}
$csv_file =$mypath;
if (($handle = fopen($csv_file, "r")) !== FALSE) {
fgetcsv($handle);
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$col[$c] = $data[$c];
}
$col1 = $col[0];
// SQL Query to insert data into DataBase
$query = "INSERT INTO pincode(Pincode) VALUES('$col1')";
$s = mysql_query($query);
}
fclose($handle);
}
}
?>
<form id="pincodeList" name="pincodeList" method="post" enctype="multipart/form-data">
<div class="row">
<div class="co-md-3 col-sm-6">
<input type="file" name="Csv" >
</div>
<div class="co-md-3 col-sm-6">
<input class="btn btn-success" type="submit" name="submit" value="Upload Csv"/>
</div>
</div>
</form>
File or Image Upload Validation using Jquery Validation
File or Image Upload Validation using Jquery Validation Example
$("#form1").validate({
rules: {
categoryBanner:{
filesize:1048576
},
},
messages: { categoryBanner: "File must be JPG, GIF or PNG, less than 1MB" },
highlight: function(element) {
$(element).css({
"background-color": "rgba(60, 141, 188, 0.52)",
"border-color": "red"
});
},
unhighlight: function(element) {
$(element).css({
"background-color": "",
"border-color": ""
});
}
});
$.validator.addMethod('filesize', function(value, element, param) {
// param = size (in bytes)
// element = element to validate (<input>)
// value = value of the element (file name)
return this.optional(element) || (element.files[0].size <= param)
});
<input type="file" name="categoryBanner" />
<input type="submit" name="submit"/>
$("#form1").validate({
rules: {
categoryBanner:{
filesize:1048576
},
},
messages: { categoryBanner: "File must be JPG, GIF or PNG, less than 1MB" },
highlight: function(element) {
$(element).css({
"background-color": "rgba(60, 141, 188, 0.52)",
"border-color": "red"
});
},
unhighlight: function(element) {
$(element).css({
"background-color": "",
"border-color": ""
});
}
});
$.validator.addMethod('filesize', function(value, element, param) {
// param = size (in bytes)
// element = element to validate (<input>)
// value = value of the element (file name)
return this.optional(element) || (element.files[0].size <= param)
});
<input type="file" name="categoryBanner" />
<input type="submit" name="submit"/>
Wednesday, 20 January 2016
Upload Multiple-image Using Webservice in PHP
Hello
Upload Multiple-image Using Webservice in PHP
<?php
if(isset($_POST['submit'])){
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
/** valiation only 1 Mb File Upload **/
if($_FILES['upload']['size'][$i] > 1048576){
$notice_image = '<div class="alert alert-info fade in">
<a title="close" aria-label="close" data-dismiss="alert" class="close" href="#">×</a>
<strong>Info!</strong> Image Size Must Be Less Than 1 Mb. Your Image is "'.$_FILES['upload']['name'][$i].'"
</div>';
}else{
$tmpFilePath =$_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "ProductImg/";
if ( ! is_dir($newFilePath)) {
mkdir($newFilePath);
}
$picture =uniqid()."_".$_FILES['upload']['name'][$i];
$mypath = "ProductImg/".$picture;
//Upload the file into the temp dir
// if(move_uploaded_file($tmpFilePath, $mypath)) {
if(!file_exists($mypath)){
//move_uploaded_file($tmpFilePath, $mypath);
/** remove Comment when not use webservice*/
if(!empty($picture))
{
$data = base64_decode($_FILES['upload']['name'][$i]);
$file = fopen($mypath, "w");
fwrite($file,$data);
fclose($file);
}
}
}
}
}
}
?>
<form method="post" enctype="multipart/form-data">
<?php echo $notice_image; ?>
<input type="file" name="upload[]" multiple="multiple" >
<input type="submit" name="submit" value="save">
</form>
Subscribe to:
Posts (Atom)