Firefox 和 Edge 不会上传多于一张图片。

huangapple go评论60阅读模式
英文:

Firefox and Edge won't upload more than one image

问题

我已经创建了一个测试页面,以重构我的fileManager类。我的问题是,无论是Firefox还是Edge,都无法上传多个图像。如果我选择多个图像,没有任何内容被传递。没有$_POST,没有$_FILES,什么都没有。以下是我简单的HTML和我正在测试的fileManager类的开始脚本:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Restricted</title>
</head>

<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" name="form">
<input type="text" name="username" placeholder="username">
<input type="file" multiple name="lFront[]" placeholder="Left Front">
<input type="file" multiple name="rFront[]" placeholder="Right Front">
<input type="file" multiple name="lRear[]" placeholder="Left Rear">
<input type="file" multiple name="rRear[]" placeholder="Right Rear">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
include_once('includes/fileManager.php');
include_once('config.php');
$root = dirname(__FILE__).'\';

if ( isset ( $_POST['submit'] ) ) {
    $file = new fileManager($root.'clientImages\', 'testfolder' , "testfolder1");

    $file->uploadFile($_FILES['rFront']);
    $file->uploadFile($_FILES['lFront']);
    $file->uploadFile($_FILES['rRear']);
    $file->uploadFile($_FILES['lRear']);
}
var_dump($_POST); // 如果我尝试上传多个图像,则此提交后不输出任何内容
?>

这是我的uploadFile函数,如果上传多个图像,var_dump始终为空:

public function uploadFile($file, $webp = NULL) {
    echo '在uploadFile<br>';
    var_dump($file);

    if ( !is_array($file) ) return false;
    // 用于存储所有图像名称的数组
    $stringName = array();
}

我会感激任何帮助或建议。

我查找了为什么响应被截断的原因。进入Firefox的about:config并将devtools.netmonitor.responseBodyLimit更改为0。这没有产生任何结果。这是一个纯粹的HTML问题。我不知道为什么它们不会上传。

英文:

I have created a test page in order to revamp my fileManager class. My problem is that neither Firefox nor Edge are uploading more than one image. If I select more than one image nothing is being passed. No $_POST,no $_FILES, nothing. Here is my simple HTML and the begining script of my fileManager class I'm testing:

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;title&gt;Restricted&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?&gt;&quot; enctype=&quot;multipart/form-data&quot; name=&quot;form&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;username&quot;&gt;
&lt;input type=&quot;file&quot; multiple name=&quot;lFront[]&quot; placeholder=&quot;Left Front&quot;&gt;
&lt;input type=&quot;file&quot; multiple name=&quot;rFront[]&quot; placeholder=&quot;Right Front&quot;&gt;
&lt;input type=&quot;file&quot; multiple name=&quot;lRear[]&quot; placeholder=&quot;Left Rear&quot;&gt;
&lt;input type=&quot;file&quot; multiple name=&quot;rRear[]&quot; placeholder=&quot;Right Rear&quot;&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;`
&lt;?php
include_once(&#39;includes/fileManager.php&#39;);
include_once(&#39;config.php&#39;);
$root = dirname(__FILE__).&#39;\\&#39;;

if ( isset ( $_POST[&#39;submit&#39;] ) ) {
$file = new fileManager($root.&#39;clientImages\\&#39;, &#39;testfolder&#39; , &quot;testfolder1&quot;);

$file-&gt;uploadFile($_FILES[&#39;rFront&#39;]);
$file-&gt;uploadFile($_FILES[&#39;lFront&#39;]);
$file-&gt;uploadFile($_FILES[&#39;rRear&#39;]);
$file-&gt;uploadFile($_FILES[&#39;lRear&#39;]);
}
var_dump($_POST); // This outputs nothing after for submission if I have more than one image trying to upload

?&gt;`

This is my uplodFile function and the var_dump is always empty if more than one image is uploaded

public function uploadFile($file, $webp = NULL) {
    echo &#39;In uploadFile&lt;br&gt;&#39;;
    var_dump($file);

if ( !is_array($file) ) return false;
    // To store all of the image names
    $stringName = array();
     }

I would appreciate any help or advice

I have looked up why the response was being truncated. went into firefox's about:config and changed devtools.netmonitor.responseBodyLimit to 0. That did not render any results. This is a straight html issue. I have no idea why they won't upload

答案1

得分: 1

CBroe是正确的。谢谢。这是一个php.ini的问题。

"> 您可能遇到了与您上传的数据量相关的POST请求大小限制之一。
"> php.net/manual/en/ini.core.php#ini.post-max-size: "如果post数据的大小大于post_max_size,则$_POST和$_FILES
"> 超级全局变量将为空。"

  • CBroe
    7小时前
英文:

CBroe was correct. Thank you. It was a php.ini issue

> You are probably running into one of the POST request size related
> limits here, with the amount of data you are uploading.
> php.net/manual/en/ini.core.php#ini.post-max-size: "If the size of post
> data is greater than post_max_size, the $_POST and $_FILES
> superglobals are empty."

  • CBroe
    7 hours ago

huangapple
  • 本文由 发表于 2023年2月23日 22:33:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75546248.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定