Top Questions

  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 12, 2017

    JQuery Ajax form using boostrap validation

     $(document).on('submit','#formid',function(){
     $(this).formValidation({
                                framework: 'bootstrap',
                                fields: {
                                    name: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The name is required'
                                            }
                                        }
                                    },
                                    email: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The email is required'
                                            }
                                        }
                                    },
                                    password: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The password is required'
                                            }
                                        }
                                    },
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                               var Formdata=$(this).serialize();
                                $.ajax({
                                    type: "POST",
                                    url: '', //add page url here
                                    data: Formdata, //send data from here,
                                    success: function(data) {
                                        alert(data);
                                    }
                                });
                            });
                     });
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 4, 2017

    Easy Multiple Image Using Codeigniter.

    if($_FILES['filename']['name']!='')
     {
           $image=array();
           $counts = count($_FILES['filename']['name']);
           $config['upload_path'] = APPPATH.'uploads/'; //create upload folder in application
                                                        // Give permission -R 777 to upload folder 
           $config['allowed_types'] = '*';
           $files = $_FILES;
           for($i=0; $i<$counts; $i  )
            {       
               if($_FILES['filename']['name'][$i]!='')
     { 
           $_FILES['filename']['name']= time().$files['filename']['name'][$i];
           $_FILES['filename']['type']= $files['filename']['type'][$i];
           $_FILES['filename']['tmp_name']= $files['filename']['tmp_name'][$i];
           $_FILES['filename']['error']= $files['filename']['error'][$i];
           $_FILES['filename']['size']= $files['filename']['size'][$i];
           $this->load->library('upload', $config);
           $this->upload->initialize($config);
           $upload= $this->upload->do_upload('familypicture');
           if($upload){
          $uu=$this->upload->data();
                $image[] =$uu['file_name'];
       }
             }
             }
       $fileToUpload = implode('|',$image);
    }
     
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 27, 2017

    using this code you can prevent required values in html5

    <script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.16.0/dev/polyfiller.js" type="text/javascript"></script>
    
    <script> 
            webshim.activeLang('en');
            webshims.polyfill('forms');
            webshims.cfg.no$Switch = true;
    </script>
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Chandigarh, India
    • Posted On : Mar 15, 2018

    You can specify a function identifier in a custom property in your .ajax() call and use the value of that in your ajaxComplete() callback.

    For example, get any ajax property while making your .ajax() call:
    function foo() {
        $.ajax({
            url: 'my-page.php',
        });
    }
    
    And then, use any of ajax property to ajaxComplete() like this:
    $('#my-unique-id').ajaxComplete(function(e, xhr, settings) { // run after all ajax complete 
        if (settings.url == 'my-page.php') { // write condition according to your requirement
            // execute you code
        } else {
            // execute you code
        }
    });
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Chandigarh, India
    • Posted On : Mar 14, 2018

    According to me if you want to remove all NEW link in wp admin area please follow this code

    add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 );
    
    function remove_wp_nodes() 
    {
        global $wp_admin_bar;   
        $wp_admin_bar->remove_node('new-content');
    }
     
  • 5.11 Years

    • Category : Php
    • Location : Chandigarh, India
    • Posted On : Apr 18, 2016

    When i click the first upload field (uploading process are success) after insert into post that corresponding media url is appear in the second field not in first. I am not sure where is the problem any suggestion would be great.

    <?php
    wp_enqueue_script('jquery');
    // This will enqueue the Media Uploader script
    wp_enqueue_media();
    ?>
        <div>
        <label for="image_url">Image</label>
        <input type="text" name="image_url" id="image_url" class="regular-text">
        <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Upload Image">
     </div>
    <script type="text/javascript">
    
    jQuery(document).ready(function($){
        $('#upload-btn').click(function(e) {
            e.preventDefault();
            var image = wp.media({ 
                title: 'Upload Image',
                // mutiple: true if you want to upload multiple files at once
                multiple: false
            }).open()
            .on('select', function(e){
                // This will return the selected image from the Media Uploader, the result is an object
                var uploaded_image = image.state().get('selection').first();
                // We convert uploaded_image to a JSON object to make accessing it easier
                // Output to the console uploaded_image
                console.log(uploaded_image);
                var image_url = uploaded_image.toJSON().url;
                // Let's assign the url value to the input field
                $('#image_url').val(image_url);
            });
        });
    });
    </script>
    
    
    
    // UPLOAD ENGINE
    function load_wp_media_files() {
        wp_enqueue_media();
    }
    add_action( 'admin_enqueue_scripts', 'load_wp_media_files' );
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Apr 6, 2016

    When we add longtext and it include special character like (',") its stop execution of query.this code help you to resolve this problem

    $desc=mysql_real_escape_string('your text');
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Oct 1, 2016

    you can drag drop all data between multiple divs

     <div id="1" dvSource dvSourceul">
    <ul id="dropul_1">
          <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" /> </li>
    </ul>
        </div>
    <div id="2">
    <ul id="dropul_2">
          <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" />
    <li class="drop"> <img alt="" src="images/Chrysanthemum.jpg" /> </li>
    </ul>
        </div>
    /********Jquery*********
    <script>
     $(function () {
                $("li.drop").draggable({
                    revert: "invalid",
                    refreshPositions: true,
                    drag: function (event, ui) {
                        ui.helper.addClass("draggable");
                       
                    },
                    stop: function (event, ui) {
                        if ($.ui.ddmanager.drop(ui.helper.data("draggable"), event)) {
                             ui.helper.removeClass("ui-draggable-dragging");
                             ui.helper.removeClass("draggable");
                        }
                        else {
                            //alert(" not dropped.");
                        }
                    }
                });
                $(".dvSourceul").droppable({
                    drop: function (event, ui ) {
                      var newId=event.target.id;
                      var aworkid=ui.draggable.attr('data-id');
                        ui.draggable.addClass("dropped");
                        $("#dropul_" newId).append(ui.draggable);
                        $.ajax({
                          type: "POST",
                          url: "update_work.php",
                          data:'id=' aworkid '&wrkid=' newId,
                          success: function(data){
                          // alert(data);
                          }
                          });
                    }
                });
            });
    
    </script>
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Aug 18, 2016

    COmpress your image size using php

    <?php
     $name = ''; $type = ''; $size = ''; $error = '';
      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);
    
           imagejpeg($image, $destination_url, $quality);
        return $destination_url;
      }
    
     if ($_POST) {
    
           if ($_FILES["file"]["error"] > 0) {
                  $error = $_FILES["file"]["error"];
            } 
            else if (($_FILES["file"]["type"] == "image/gif") || 
         ($_FILES["file"]["type"] == "image/jpeg") || 
         ($_FILES["file"]["type"] == "image/png") || 
          ($_FILES["file"]["type"] == "image/pjpeg")) {
    
                 $url = 'destination .jpg';
    
                  $filename = compress_image($_FILES["file"]["tmp_name"], $url, 80);
                  $buffer = file_get_contents($url);
    
                  /* Force download dialog... */
                  header("Content-Type: application/force-download");
                 header("Content-Type: application/octet-stream");
                 header("Content-Type: application/download");
    
         /* Don't allow caching... */
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    
                  /* Set data type, size and filename */
                  header("Content-Type: application/octet-stream");
                 header("Content-Transfer-Encoding: binary");
                  header("Content-Length: " . strlen($buffer));
                 header("Content-Disposition: attachment; filename=$url");
    
                 /* Send our file... */
                  echo $buffer;
           }else {
                 $error = "Uploaded image should be jpg or gif or png";
            }
     }
    ?>
    <html>
          <head>
                <title>Php code compress the image</title>
          </head>
         <body>
    
        <div class="message">
                         <?php
                            if($_POST){
                               if ($error) {
                                   ?>
                                   <label class="error"><?php echo $error; ?></label>
                            <?php
                                    }
                             }
                         ?>
                     </div>
        <fieldset class="well">
                       <legend>Upload Image:</legend>                
          <form action="" name="myform" id="myform" method="post" enctype="multipart/form-data">
            <ul>
                        <li>
                <label>Upload:</label>
                                          <input type="file" name="file" id="file"/>
              </li>
             <li>
                <input type="submit" name="submit" id="submit" class="submit btn-success"/>
             </li>
           </ul>
         </form>
       </fieldset>
     </body>
    </html>
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Feb 17, 2018

    Website visitor using php.

    $datei = fopen(APPPATH."/cache/countlog.txt","r");
    $count = fgets($datei,1000);
    fclose($datei);
    $count=$count +  1 ;
    echo "$count" ;
    // opens countlog.txt to change new hit number
    $datei = fopen(APPPATH."/cache/countlog.txt","w");
    fwrite($datei, $count);
    fclose($datei);