窗口8中的文件上载限制

时间:2014-11-25 13:21:44

标签: php file-upload

我有一个简单的文件上传代码,代码在窗口xp上运行良好,我测试上传大于100kb,但在窗口8我使用相同的代码,我只能上传最大60kb文件, 是什么原因,窗口8上有没有错误?或者还有任何其他可能导致限制上传文件的问题。 我也尝试在安装了Windows 8.1的另一个系统上的代码,但我发现同样的问题... 注意:它不是关于php.ini,也不关于代码,它是关于逻辑错误的,所以我该如何解决? 当我尝试上传大小超过60kb的文件时,浏览器就会加载。

的index.php

<!DOCTYPE html>
<head>
    <title>Index</title>
</head>
<html>
<body>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

upload.php的

<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
    && $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>

1 个答案:

答案 0 :(得分:0)

尝试更改xampp版本并希望它能解决问题....