Wednesday, January 30, 2013

Basic UNIX commands



Below are the basic unix commands which may help you while using PUTTY to access the server. Move, copy, view the pages from folder to other destination. All other basic stuff syntax are given below


If there are images in this attachment, they will not be displayed.  Download the original attachment
Unix Basic Commands

Copy:

cp sorce_file target_file  :copies only if the files are in current direc

cp -r sor_DIR target_dir (to copy directories)

Move/Rename;

mv file1 file2

mv -i f1 f2 (asks for permision to move or not)

Remove:

rm filename

rm -r file (to remove directory structure)

rm -i file ( asks for permision to move or not)

view:

cat filename ( to view the complete file content)

To extract or unzip files:

unzip file ( extracts file to current dir)

To uncompress

uncompress filename

To compress

compress filename

To change directory

cd path

to list files in current dir

ls

ls -l (long list of files : gives acess permision,creation date..etc)

    -a(list all files satarting with a " .")

to make a dir

mkdir name or md name

to remove

rmdir dir_name

to clear the screen

clear (clears the windoe or terminal)

help commands

man <comd name> (displays the mannual page)

whatis <cammnd> (gives description)

date (to dispaly the date)

to count the words

wc filename (gives lines,words,characters

wc -l file (only lines)

wc -c file(only characters)

wc -w file(onbly words)

df ( displays the amount of free space)

grep (search a file for matching pattern)

grep [optioln]<regularExpression filename

eg: grep [a-z]*.c filename

Wednesday, January 16, 2013

Upload huge files in PHP


When we try to upload huge files using PHP, we face many issues to upload. One of them might be the php_value upload_max_filesize which is by default 2M in php.ini

Still we may have other issues which we need to do fix them. Below are the steps we need to add in htaccess to fix the large file uploads.


php_value upload_max_filesize 10M
php_value post_max_size 64M
php_value max_execution_time 300


Thursday, January 3, 2013

javascript validation for file upload

Below is the article for adding javascript validation (or) jquery validation for a file upload that makes our life easier whether the file upload is a valid type or not.


if($('#upload_file').val() != '')
{
        var _validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png"]; // Can change the extensions if we need for doc type or something else
        if($('#upload_file').val() != '')
        {
            var sFileName = $('#upload_file').val();
            var blnValid = false;
            for (var j = 0; j < _validFileExtensions.length; j++)
            {
                var sCurExtension = _validFileExtensions[j];
                if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
                    blnValid = true;
                    break;
                }
            }
            if(!blnValid)
            {
               alert("Sorry, " + sFileName + " is invalid, allowed extensions are: " + _validFileExtensions.join(", "));
                $('#upload_file').focus();
                return false;
            }
        }
 }