0

因此,当我单击输入类型图像时,我尝试打开上传文件输入。当我单击图像时,会出现上传文件窗口,但是当我选择一个文件时,它不会加载(名称不会出现,而不是“未选择文件”)。此外,如果表单上有信息并且单击图像按钮,则先前的输入将被清空。

当我单击上传文件而不是图像时,一切正常,没有任何内容被清空并且图像正确加载。这是代码,希望你能帮助我:

HTML 表单:

        <form class='register-form-user-frmt' action='' method='post' enctype="multipart/form-data" >
            <span class='register-form-user-email'> 
                E-mail: <br> <input type='email' name='register-form-user-email' />
            </span>
            <span class='register-form-user-name'> 
                On-page name: <br> <input type='text' name='register-form-user-name' />
            </span>
            <span class='register-form-user-password'> 
                Password: <br> <input type='password' name='register-form-user-password' />
            </span>
            <span class='register-form-user-password-repeat'> 
                Check password: <br> <input type='password' name='register-form-user-password-repeat' />
            </span>
            <span class='register-form-user-image-upload-hidden'> 
                <input type='file' id='register-form-user-image-upload-hidden' name='photo'/>
            </span>
            <span class='register-form-user-submit'> 
                <input type='submit' name='register-form-user-submit' value='Submit' />
            </span>
            <span class='register-form-user-image-button'> 
                Upload image: <br> <input type='image' name='register-form-user-image-user-button' src='images/camera upload logo.png' />
            </span>
        </form>

查询:

$(document).ready(function() {
$('.register-form-user-image-button').click(function() {
    $('#register-form-user-image-upload-hidden').click();
});
});

谢谢。

4

1 回答 1

-1

你可以用这个

<span class='register-form-user-image-button'> 
    Upload image: <br> <input type='file' name='register-form-user-image-user-button' src='images/camera upload logo.png' />
</span>

在此之后,创建 php 文件以过滤您的文件类型是否为 jpg、bmp 等。是参考。这将在没有 jquery 的情况下工作。

于 2013-09-28T05:36:43.400 回答