Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ((($_FILES['profile_picture']['type'] == 'image/gif') || ($_FILES['profile_picture']['type'] == 'image/jpeg') || ($_FILES['profile_picture']['type'] == 'image/png')))
- function checkFile() {
- var filename = document.getElementById("upload_file").value;
- var ext = getExt(filename);
- // alert(filename.files[0].filesize);
- // alert(ext);
- if(ext == "gif" || ext == "jpg" || ext=="png")
- return true;
- alert("Please upload .gif, .jpg and .png files only.");
- document.getElementById("upload_file").value='';
- return false;
- }
- function getExt(filename) {
- var dot_pos = filename.lastIndexOf(".");
- if(dot_pos == -1)
- return "";
- return filename.substr(dot_pos+1).toLowerCase();
- }
- $type =array('jpg','gif');
- foreach($type as $val){
- if($_FILES['filename']['type'] == 'image/$val')
- {
- echo "its an image file";
- }
- else{
- echo "invalid image file"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement