Input <input type=”file” onchange=”ValidateFile(this);” id=”uploaded_file”> Function for checking upon on change for uploaded file function ValidateFile(file){ var FileSize = file.files[0].size / 1024 / 1024; //In MB var filePath = file.files[0].name; var extension = filePath.substr((filePath.lastIndexOf(‘.’) +1)); var allowed_extension = [“jpg”,”png”,”jpeg”]; if (FileSize > 2) { […]
Prevent Direct Calling for PHP scripts, Only Allow Ajax Calling
The Code below is useful to prevent direct calling. #Only Allow Ajax Call if(!($_SERVER[‘HTTP_X_REQUESTED_WITH’] == ‘XMLHttpRequest’ && $_SERVER[‘HTTP_X_REQUESTED_WITH’])) { echo “Access Denied”; exit(); }
SSH Trick
How To SSH run command without key-in password again echo < password > | ssh username@host ‘sudo -S < command >’ Running Two SSH Command line for sqldump ssh -t username@host ‘mysqldump -u {DB_USER} -p”{DB_PASS}” {DB_NAME}’ > dump.sql | ssh -t username@host ‘cat dump.sql’ > local.sql