Skip to content

Instantly share code, notes, and snippets.

View Guley's full-sized avatar
🎯
Focusing

Gulshan Guley

🎯
Focusing
View GitHub Profile
<input type='file' name="image" onchange="preview(this);" multiple="multiple" />
<div id='previewImg'></div>
<script>
window.preview = function (input) {
if (input.files && input.files[0]) {
$(input.files).each(function () {
var reader = new FileReader();
reader.readAsDataURL(this);
reader.onload = function (e) {
@Guley
Guley / php-image-corrupted
Last active April 23, 2018 06:39
Check if image is corrupted using php
$tempFile = $_SERVER["DOCUMENT_ROOT"]. 'images/image.jpeg';
$im = @imagecreatefromjpeg($tempFile);
if(empty($im)){
return false;
}else{
return true;
}
@Guley
Guley / base64toimage.php
Created May 3, 2018 06:02
PHP Base64 to image
$data = '/*Add you base64 encode data*/';
$encoded_string = base64_encode($data);
if(!empty($encoded_string)){
$imgdata = base64_decode($encoded_string);
$f = finfo_open();
$mime_type = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE);
$img = 'data:'.$mime_type.';base64,'.$encoded_string;
$fileType = '';
$buffer ='<xml><item><id>1</id><name>Test</name></item></xml>';
$xml = new SimpleXMLElement($buffer);
$data = json_encode($xml, JSON_PRETTY_PRINT);
$data2 = json_decode($data);
@Guley
Guley / CKEDITOR-MULIPLE_TEXTAERA
Created June 8, 2018 10:09
Use ckeditor for multiple texarea on same page
<textarea class="form-control category_content" name="category_content[1]" id="desc_1" required>
<textarea class="form-control category_content" name="category_content[2]" id="desc_2" required>
<textarea class="form-control category_content" name="category_content[3]" id="desc_3" required>
$('.category_content').each(function(e){
CKEDITOR.replace( $(this).attr('id'), {
height: '400px',
toolbar: [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
$error= ' Test log file';
$myfile = file_put_contents(get_template_directory() . '/logs.php', $error.PHP_EOL , FILE_APPEND | LOCK_EX);
<!DOCTYPE html>
<html>
<head>
<title>Snippet Random Numbers</title>
</head>
<body>
<div class="container">
<div class="row">
<a href="javascript:;" data-value='5'>Get Random number (5)</a><br>
<a href="javascript:;" data-value='10'>Get Random number (10)</a><br>
@Guley
Guley / Ajax-With-Authorization
Last active July 30, 2018 06:09
Jquery Ajax With Authorization
var postvalues = {
"key": 'test',
"id": 1
};
$.ajax({
url: 'http://www.example.com/check/',
type: 'POST',
dataType: "json",
data: postvalues,
@Guley
Guley / Bypass htdocs
Created August 20, 2018 05:23
Bypass htdocs folder to your own directory in linux
Run this command to stop xampp:
sudo /opt/lampp/lampp stop
Open /opt/lampp/etc/httpd.conf
Change your_folder to the folder you wanna use
DocumentRoot "/home/username/your_folder"
<Directory "/home/username/your_folder">
public function sendmail($maildata, $to, $subject, $attachments = [])
{
require_once(APPPATH.'third_party/PHPMailer/PHPMailerAutoload.php');
//Create a new PHPMailer instance
$mail = new PHPMailer;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,