【问题标题】:Submitting an image alongside a form with one button用一个按钮在表单旁边提交图像
【发布时间】:2020-10-24 16:16:26
【问题描述】:

我有一个提交到我的数据库的常规表单,但我想在表单中包含文件上传,以便使用 PHP post 接收预期表中的表单输入并接收上传的图像。

【问题讨论】:

    标签: php html forms submit


    【解决方案1】:

    使用<input type="file"> 在表单中包含文件上传。

    【讨论】:

      【解决方案2】:

      使用类似的东西将文件以及其他输入发送到处理页面,您可以在其中访问文件和发布变量。

      <form action="#" method="post" enctype="multipart/form-data">
      <input type="text" name="txtbox">
      <br />
      <input type="file" name="filebox">
      <br />
      <input type="submit" name="submit" value="submit">
      </form>
      

      提交后,您可以从 $_FILES 和 $_POST 访问数据

      【讨论】:

        【解决方案3】:

        HTML 中有多种输入类型,如下所示:

        <input type="button">
        <input type="checkbox">
        <input type="color">
        <input type="date">
        <input type="datetime-local">
        <input type="email">
        <input type="file">
        <input type="hidden">
        <input type="image">
        <input type="month">
        <input type="number">
        <input type="password">
        <input type="radio">
        <input type="range">
        <input type="reset">
        <input type="search">
        <input type="submit">
        <input type="tel">
        <input type="text">
        <input type="time">
        <input type="url">
        <input type="week">
        

        上述每个输入都需要满足不同的条件和格式。

        对于您的查询,答案是:

        <input type="file">
        

        适用于需要以文件格式输入的网页。或者,

        <input type="image">
        

        适用于需要以图像格式输入的网页。

        欲了解更多详情,请查看以下链接以获取帮助:

        https://www.w3schools.com/html/html_form_input_types.asp

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-12-25
          • 2014-01-31
          • 2012-01-23
          • 1970-01-01
          • 2012-04-29
          • 1970-01-01
          相关资源
          最近更新 更多