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

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

File input doesnt show up in $_POST

问题

  1. 我有这个输入表单字段:
  2. ```html
  3. <div class="inputContainer">
  4. <img src="images/3_randomfilm.jpeg" alt="image" width="100">
  5. <label for="radioEdit1" class="labelForm radioLabel">Afbeelding
  6. <input type="radio" name="radio" value="radioAfbeelding" id="radioEdit1" onclick="showEditInput('file')" checked />
  7. <span class="checkmark"></span>
  8. </label>
  9. <label for="radioEdit2" class="labelForm radioLabel">Video
  10. <input type="radio" name="radio" value="radioYoutube" id="radioEdit2" onclick="showEditInput('url')"/>
  11. <span class="checkmark"></span>
  12. </label>
  13. <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">
  14. <input type="url" id="urlEditInput" name="youtube_url" class="input hidden" value="">
  15. </div>

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

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

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

  1. $_POST['fileEditInput']

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

英文:

I have this input form field:

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

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

  1. <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:

  1. $_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:

确定