简体   繁体   English

在 FORM 标签内发布图片

[英]POST image inside FORM tag

I want to post an entire IMAGE when SUBMIT button is clicked.单击提交按钮时,我想发布整个图像。

<FORM action=".." method=post>
        <img src="...."/>
        <input type="submit" value="Click"/>
</FORM>

Is it possible?可能吗?

Please help me......请帮我......

Thanks in advance.....提前致谢.....

Are you looking to upload an image?您要上传图片吗? If so, then you'll want the "file" HTML input element type:如果是这样,那么您将需要“文件”HTML input元素类型:

<input type="file"/>

And include enctype="multipart/form-data" in your form tag.并在您的表单标签中包含enctype="multipart/form-data"

Here's a basic tutorial and more info: http://www.tizag.com/phpT/fileupload.php这是一个基本教程和更多信息: http ://www.tizag.com/phpT/fileupload.php

if you want to post an image inside a form, you should have that image already on your server.如果您想在表单中发布图像,您的服务器上应该已经有该图像。 In which case all you have to do is put a hidden element on the form with the location of that image and voila you have the image in the form在这种情况下,您所要做的就是在表单上放置一个隐藏元素以及该图像的位置,瞧,您在表单中就有了图像

<input type="hidden" name="image_location" id="image_location" value="/images/bleh.jpg" />

You can do it like this:你可以这样做:

<FORM action=".." method="POST" enctype="multipart/form-data">
    <input type="file" id="file" placeholder="upload a file"       
    name="file">
    <button type="submit">Submit</button>
</FORM>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM