如何只将excel和csv文件上传到上传文件夹

时间:2017-03-06 09:53:19

标签: php html excel csv

我只需要授予访问权限,只能将.csv和.xlsx文件上传到我的上传文件夹。那么我应该在以下编码中进行哪些修改。

<?php  if (isset($_POST["submit"])) {
    if (isset($_FILES["file"])) {
//        $_SESSION['date_ss'] = $_POST['date_ss'];
//if there was an error uploading the file
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        } else {
            if (file_exists($_FILES["file"]["name"])) {
                unlink($_FILES["file"]["name"]);
            }

            $target_path = "uploads/";
            $target_location = $target_path . basename($_FILES['file']['name']);
            $_SESSION['target_location'] = $target_location;


//            $datess = $_POST['date_ss'];
            move_uploaded_file($_FILES["file"]["tmp_name"], $target_location);
            $uploadedStatus = 1;

        }
    } else {
        echo "No file selected <br />";
    }
}
?>

1 个答案:

答案 0 :(得分:0)

public static class Extensions
{
    public A ToA(this B b)
    {
        return new A() 
        {
            p1 = b_obj.p1,
            p3 = b_obj.p3,
        };
    }
}