我已经做了一个上传表格。但我希望用户能够上传 .zip 文件和 .rar 文件。我已经尝试过以下方法:
$ftp_server = "myserver";
$ftp_user_name = "myuser";
$ftp_user_pass = "mypass";
$source_file = $_FILES['file']['tmp_name'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('.', $filename);
$fileActualExt = strtolower(end($fileExt));
$destination_folder = "/public_html/wp/wp-content/plugins/AbonneerProgrammas/FilesUpload";
$destination_file = $destination_folder . "/" . basename($_FILES['file']['name']);
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
$allowed = array('zip', 'rar');
if(in_array($fileActualExt, $allowed)) {
//my upload code
}else {
echo "You are not allowed to upload this file.";
}
它没有显示任何错误。它只进入 else 内部。当我上传 .zip 文件时它也会这样做,我不知道出了什么问题。
catspeake