Check File Type in PHP

We can find the file type in two ways,
(i) by mime type
(ii) by get the extension

as follows

if($_FILES[newfile][type] ==’application/x-msdos-program’ || strtolower(end(explode(".", $_FILES[newfile][name]))) == ‘exe’)
error(‘Attached file type is not allowed’, $_SERVER["HTTP_REFERER"]);

newfile is the actual parameter name of FILE.

Bash Loop Array

This is script to copy a folder from on place to more than one places.

#list the folder/path names in below array
context=( "folder1" "folder2" )
for i in "${context[@]}"
cp -R /var/www/folder/foldertocopy /var/www/newplaces/$i

This will copy the foldertocopy to all specified folders.