From the above code I am getting no good result fromPHP Code:#If upload button is clicked
if(isset($_POST['s_reg'])){
$reg = $_REQUEST['s_reg'];
#Get file extension and size
$msize = $_REQUEST['max_size']; //Max allowed file size
$size = $_FILES['passport']['size']; //Actual file size
$type = $_FILES['passport']['type'];
#Check File type
if($type != 'image/pjpeg' || $type != 'image/gif' || $type != 'image/x-png'){
$_SESSION['upload'] = "<span class='error'>This image format is not supported!</span>";
}else{
#Check file size
if($size <= $msize){
#if conditions are met, upload file
$file = basename($_FILES['passport']['name']);
$rename_file = $reg.$file; //Rename file with prefix of student registration number
$uploaddir = $passport_dir; //Declared in userconfig.inc.php
$uploadfile = $uploaddir.$rename_file;
if (move_uploaded_file($_FILES['passport']['tmp_name'], $uploadfile)){
$_SESSION['upload'] = "<span class='response'>Passport uploaded successfully</span>";
#Update user passport URL
$p_name_after = $rename_file; //Passport name after upload
$up_q = "UPDATE students SET passport_url = '".$passport_dir_a.$p_name_after."'
WHERE s_reg = '".$reg."'";
$up_result = $db_q($up_q, $conn);
?>
<script language="javascript" type="text/javascript">
function reloadIt(){
opener.location.reload();
self.close();
}
setTimeout('reloadIt()',3000);
/*setTimeout("opener.location.reload(true)",3000)
self.close();*/
</script>
<?php
} else {
$_SESSION['upload'] = "<span class='error'>Passport upload has failed!</span>";
}
}else{
$_SESSION['upload'] = "<span class='error'>Passport size is too large!</span>";
}
}
}
if($type != 'image/pjpeg' || $type != 'image/gif' || $type != 'image/x-png'){
all kind of file is not supported with the above if but with
if($type != 'image/pjpeg'){
only .jpeg extension is supported.
what could be the problem?


Reply With Quote
Bookmarks