You haved opened Category: PHP Tricks

File Size Validation using javascript

File Size Validation using jQuery

In this tutorial we are going to see form file input validation using jQuery. In previous tutorial we do this validation using PHP to check if the file input is empty or not.

In this jQuery example, we are validating file size before submitting it for upload. If the file size exceeds 2 MB then the jQuery function will return false.

in PHP Tricks
by author
Abubakar
"True Friend"

You haved opened Category: PHP Tricks

File size convert kb function in php

PHP filesize MB/KB conversion

How can I convert the output of PHP's filesize() function to a nice format with MegaBytes, KiloBytes etc?

you can use this fuction in your php website it will convert file size it is very useful function i am also using it.

<?php
    function formatSizeUnits($bytes)
    {
        if ($bytes >= 1073741824)
        {
            $bytes = number_format($bytes / 1073741824, 2) . 'GB';
        }
        elseif ($bytes >= 1048576)
        {
            $bytes = number_format($bytes / 1048576, 2) . 'MB';
        }
        elseif ($bytes >= 1024)
        {
            $bytes = number_format($bytes / 1024, 2) . 'KB';
        }
        elseif ($bytes > 1)
        {
            $bytes = $bytes . 'bytes';
        }
        elseif ($bytes == 1)
        {
            $bytes = $bytes . 'byte';
        }
        else
        {
            $bytes = '0 bytes';
        }

        return $bytes;
}

?>
in PHP Tricks
by author
Abubakar
"True Friend"

You haved opened Category: PHP Tricks

PHP header redirect not working

If header redirect is not working you can use javascript just make a simple php function for redirect page and put simple javascript.

<?php
    function redirect_to($new_location) {

	 echo("");
	
   }
?>

in PHP Tricks
by author
Abubakar
"True Friend"