PHP上传脚本不会上传flash文件.为什么?


PHP upload script will not upload flash files. Why?

我在尝试让这个上传脚本工作时遇到了问题。它不上传.swf,尽管脚本本身应该可以工作,但我使用了一个图像上传器的脚本并对其进行了编辑,使其可以与.swf文件一起工作,但PHP中似乎存在一个问题,不允许上传这些类型的文件。

有人能帮我吗?

这是html

    <!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    Select game (*.swf) to upload and add to the list of games:
    <input type="file" name="gameToUpload" id="gameToUpload">
    <input type="text" name="nameOfGame" id="nameOfGame">
    <input type="submit" value="Upload Game" name="submit">
</form>
</body>
</html> 

这是PHP

<?php
    include('init.php');
    //Reminder to self: Turn off when finished coding!!
    error_reporting(-1);     
    //Some querys and variables used later on
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["gameToUpload"]["name"]);
    $uploadOk = 1;
    $gameFileType = pathinfo($target_file,PATHINFO_EXTENSION);
    $gameName = $_POST["nameOfGame"];
    $query = "INSERT INTO `beoordelingen`.`beoordeling` (`ID`, `file`, `Spel`) VALUES (NULL, '{$target_file}', '{$gameName}')";
    //If submit is pressed
    if (isset($_POST['submit'])) {
        $check = $_FILES["gameToUpload"]["tmp_name"];
        //Check if file already exists in folder
        if (file_exists($target_file)) {
            echo "This game is already in the folder.";
            $uploadOk = 0;
        }
        //Check if the file type is .SWF
    if ($gameFileType != "swf") {
            echo "Sorry, only .swf is allowed for this page.";
            $uploadOk = 0;
        }
        //When any errors occured do not go passed this statement
        if ($uploadOk === 0) {
            echo "Sorry, your file wasn't uploaded.";
        }
    //If no errors have occured then continue with this
    else {
        //Move the file from the temporary folder to the final destination
        if (move_uploaded_file($_FILES["gameToUpload"]["tmp_name"], $target_file)) {
            echo "The file " . basename($_FILES["gameToUpload"]["name"]). " has been uploaded.";
            //Update the mysql database
            $conn->query($query);
        }
        //If something bad happened while trying to move the file. Show this message to the user.
        else {
            echo "Sorry, there was an error uploading the file.";
        }
      }
    }
?>

你好,你的脚本正在运行,我已经尝试过这个文件,运行良好。但当我将文件扩展名更改为SWF时,我收到了以下错误:"对不起,此页面只允许.SWF。对不起,您的文件没有上传"。您还必须检查您的文件夹权限,当然,上传文件夹必须与php文件处于同一级别。