Hello! I have been trying to figure out why an upload script doesn't seem to work like it should but I couldn't understand why so maybe somebody here can help me out a bit please. Here is the function:
function uploadFile($conn,$newsid,$table_name,$linkImg,$align) {
global $msg,$maxSize;
if ( $_FILES['userfile']['size']!=0 && $_FILES['userfile']['size']<($maxSize*1000)
&& ($_FILES['userfile']['type'] == 'image/jpg'
|| $_FILES['userfile']['type'] == 'image/jpeg'
|| $_FILES['userfile']['type'] == 'image/pjpeg') ) {
$uploadfile = 'images/' . $newsid . '.jpg';
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
@chmod($uploadfile, 0666);
$msg.= ' Image successfully uploaded.';
if (updateImg($conn, $newsid, $table_name, $newsid.'.jpg' , $linkImg , $align )) return true;
else return false;
}
else {
$msg.= ' Error: possible file upload attack!';
return false;
}
}
else {
if ($_FILES['userfile']['size']==0 && $_FILES['userfile']['name']=='') {
$msg .= ' Image not submitted.';
if (updateImg($conn, $newsid, $table_name, '' , $linkImg , $align )) return true;
else return false;
}
else $msg .= ' Image upload failed, wrong file.';
}
}