Php 窗口8中的文件上载限制
我有一个简单的文件上传代码,该代码在Windows xp上运行得很好,我测试上传大于100kb的文件,但在Windows 8中我使用相同的代码,我最多只能上传60kb的文件, 原因是什么,windows8上有任何bug吗?或者存在任何其他可能导致限制上载文件的问题。 我也在另一个安装了Windows8.1的系统上尝试了这段代码,但我发现了同样的问题。。。 注意:这不是关于php.ini的问题,也不是关于代码的问题,而是关于逻辑错误的问题,那么我该如何解决它呢? 当我试图上传一个大于60kb的文件时,浏览器在加载时卡住了 index.phpPhp 窗口8中的文件上载限制,php,file-upload,Php,File Upload,我有一个简单的文件上传代码,该代码在Windows xp上运行得很好,我测试上传大于100kb的文件,但在Windows 8中我使用相同的代码,我最多只能上传60kb的文件, 原因是什么,windows8上有任何bug吗?或者存在任何其他可能导致限制上载文件的问题。 我也在另一个安装了Windows8.1的系统上尝试了这段代码,但我发现了同样的问题。。。 注意:这不是关于php.ini的问题,也不是关于代码的问题,而是关于逻辑错误的问题,那么我该如何解决它呢? 当我试图上传一个大于60kb的文件
<!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>
<?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.";
}
}
?>
指数
选择要上载的图像:
upload.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>
<?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.";
}
}
?>
尝试更改xammp版本,并希望它能解决问题….我清楚地提到,我无法上载大于60kb的文件,并且php.ini中文件上载的默认大小为2MB,请再次阅读我的问题…你说的是什么逻辑错误?Win8不限制浏览器操作。您是否考虑过在表单中添加
,并设置适合您的值?使用'var_dump'和'exit'确定脚本执行的距离,这将缩小可能性。我只安装了最新版本的xammp,就这样。