Tuesday 20 January 2015

get image height and width in php

<?php list($width, $height) = getimagesize('path_to_image');
echo $width."<br/>";
echo $height; 
?>
 
 
 
Powered by Crawlers group

how to count array value in jquery

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
function chksame(cl) {
var newArray = new Array();

var classnm = $(cl).attr("class");
 
var array = $("input[class^= '" + classnm + "']"); //get value by class name

$.each(array, function(key, value) {
card_value = array.eq(key).val();
   newArray.push(card_value);//push value in array.
  
});

counts = {};
jQuery.each(newArray, function(key,value) {
  if (!counts.hasOwnProperty(value)) {
    counts[value] = 1; //set count value
  } else {
    counts[value]++;
  }
 
  if(counts[value]>1 && value!="") //check if value greater than then alert massege.
  {
  alert("This order already exist");
  $(cl).val("");
  }
});
return false;
}
</script>

Powered by Crawlers group

Thursday 8 January 2015

download file in php

function Download($path, $speed = null)
{
if (is_file($path) === true)
    {
set_time_limit(0);
while (ob_get_level() > 0)
        {
            ob_end_clean();
        }
$size = sprintf('%u', filesize($path));
        $speed = (is_null($speed) === true) ? $size : intval($speed) * 1024;
        header('Expires: 0');
        header('Pragma: public');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Type: application/octet-stream');
        header('Content-Length: ' . $size);
        header('Content-Disposition: attachment; filename="' . basename($path) . '"');
        header('Content-Transfer-Encoding: binary');

        for ($i = 0; $i <= $size; $i = $i + $speed)
        {
            echo file_get_contents($path, false, null, $i, $speed);

            while (ob_get_level() > 0)
            {
                ob_end_clean();
            }

            flush();
            sleep(1);
        }

        exit();
    }

    return false;
}
echo Download($file_path,500);