css 使用HTML div like form

b4lqfgs4  于 2023-06-25  发布在  其他
关注(0)|答案(1)|浏览(128)

我做了一个网站,允许你上传一张图片,命名它,然后提交它的数据给PHP code。到目前为止,我只使用普通的HTML和PHP,但我想添加Bulma CSS库。
Right now the HTML code looks like this:

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="emote" id="emote">
    <br>
    Emote name:
    <input type ="text" name="emotename" id="emotename">
    <br>
    <input type="submit" value="Upload Emote" name="submit">
</form>

但是库要求我使用div s而不是form。代码如下所示:

<form action="upload.php" method="post" enctype="multipart/form-data">
    <div class="field">
        <label class="label">Emote name</label>
        <div class="control">
            <input class="input" type="text" placeholder="Emote name..." id="emotename">
        </div>
    </div>
    <div class="file">
        <label class="file-label">
            <input class="file-input" type="file" name="resume" id="emote">
            <span class="file-cta">
                <span class="file-icon">
                    <i class="fas fa-upload"></i>
                </span>
                <span class="file-label">
                    Choose a file...
                </span>
            </span>
        </label>
    </div>
    <div class="field is-grouped">
        <div class="control">
            <input class="button" type="submit" value="Submit">
        </div>
        <div class="control">
            <button class="button is-link is-light">Cancel</button>
        </div>
    </div>
</form>

当我点击Submit PHP错误:“你需要填写所有字段。”

8mmmxcuj

8mmmxcuj1#

工作form看起来像这样:

<form action="upload.php" method="post" enctype="multipart/form-data">
    <div class="field">
        <label class="label">Emote name</label>
        <div class="control">
            <input class="input" type="text" placeholder="Emote name..." name="emotename" id="emotename">
        </div>
    </div>
    <div class="file">
        <label class="file-label">
            <input class="file-input" type="file" name="emote" id="emote">
            <span class="file-cta">
                <span class="file-icon">
                    <i class="fas fa-upload"></i>
                </span>
                <span class="file-label">
                    Choose a file...
                </span>
            </span>
        </label>
    </div>
    <div class="field is-grouped">
        <div class="control">
            <input class="button" type="submit" value="Submit">
        </div>
        <div class="control">
            <button class="button is-link is-light">Cancel</button>
        </div>
    </div>
</form>

相关问题