我在我的消息传递系统中添加了一个上传文件的东西,当我尝试按file_type对文件进行排序时,它永远不会起作用。
这是我的上传文件功能:
<?php
session_start();
include_once "../backend/messaging-functions.php";
include_once '../backend/databaseconn.php';
$errors= array();
$file_name = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];
$file_tmp = $_FILES['file']['tmp_name'];
$file_type = $_FILES['file']['type'];
$file_ext= strtolower(end(explode('.',$file_name)));
$extensions= array("jpeg","jpg","png","mp4","MP4","MOV","PNG","JPG","mov","JPEG");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG, PNG or a MP4 file type!";
}
if($file_size > 16777216) {
$errors[]='File size must be at MOST 16 MB!';
}
if(empty($errors)==true) {
move_uploaded_file($file_tmp,'../userfiles/'.$file_name);
$fileplace = '../userfiles/'.$file_name;
if ($file_type == "image/jpg" or "image/jpeg" or "image/png" or "image/PNG" or "image/JPG" or "image/JPEG") {
$date = date("y-m-d h:i:s");
$filetype = "image";
$myId = $_SESSION['user-id'];
$message = $fileplace;
$groupId = mysqli_real_escape_string($conn, $_GET['id']);
addMessage($myId, $groupId, $date, $message, $filetype);
}
if ($file_type == "video/mp4" or "video/mpeg4") {
$date = date("y-m-d h:i:s");
$filedtype = "video";
$myId = $_SESSION['user-id'];
$message = $fileplace;
$groupId = mysqli_real_escape_string($conn, $_GET['id']);
addMessage($myId, $groupId, $date, $message, $filedtype);
}
}
?>
我尝试添加一个exit();在第一个 if 之后的事情,这样它就不会触发两次,而是从不称自己为视频。请帮忙
UYOU