文件输入不会显示在$_POST中。

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

File input doesnt show up in $_POST

问题

我有这个输入表单字段:

```html
              <div class="inputContainer">
                <img src="images/3_randomfilm.jpeg" alt="image" width="100">
                <label for="radioEdit1" class="labelForm radioLabel">Afbeelding
                        <input type="radio" name="radio" value="radioAfbeelding" id="radioEdit1" onclick="showEditInput('file')" checked />
                        <span class="checkmark"></span>
                </label>
                <label for="radioEdit2" class="labelForm radioLabel">Video
                    <input type="radio" name="radio" value="radioYoutube" id="radioEdit2" onclick="showEditInput('url')"/>
                    <span class="checkmark"></span>
                </label>
                        <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">
                        <input type="url" id="urlEditInput" name="youtube_url" class="input hidden" value="">
              </div>

当我尝试提交时,除了fileEditInput之外,所有内容都会提交。我就是不明白... 为什么它不提交?

 <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">

如果你想知道,这是我在PHP中提交的方式:

$_POST['fileEditInput']

我尝试过给它另一个名称,但我不知道问题出在哪里。也许我打错了什么,但现在我就是看不到...
我希望你们都能帮帮我...

英文:

I have this input form field:

              <div class="inputContainer">
                <img src="images/3_randomfilm.jpeg" alt="image" width="100">
                <label for="radioEdit1" class="labelForm radioLabel">Afbeelding
                        <input type="radio" name="radio" value="radioAfbeelding" id="radioEdit1" onclick="showEditInput('file')" checked />
                        <span class="checkmark"></span>
                </label>
                <label for="radioEdit2" class="labelForm radioLabel">Video
                    <input type="radio" name="radio" value="radioYoutube" id="radioEdit2" onclick="showEditInput('url')"/>
                    <span class="checkmark"></span>
                </label>
                        <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">
                        <input type="url" id="urlEditInput" name="youtube_url" class="input hidden" value="">
              </div>

When I try to post this, everything posts except the fileEditInput. I just dont get it... Why does this not post?

 <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">

This is how I post it in PHP if you want to know:

$_POST['fileEditInput']

I tried giving it another name, but I just dont know how this can be wrong. Maybe I mistyped something but right now I cant just see it...

I hope you all can help me...

答案1

得分: 0

尝试使用$_FILES而不是$_POST。

通过表单上传的文件将位于$_FILES中,而不是$_POST。表单的其余数据将位于$_POST中。

英文:

Try using $_FILES instead of $_POST

Files uploaded through a form will be in $_FILES and not in $_POST. The rest of the form data will be in $_POST.

huangapple
  • 本文由 发表于 2023年7月23日 17:14:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747464.html
匿名

发表评论

匿名网友

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

确定