[英]POST when clicking an image
I have a "delete" icon with a relative position in the upper-right corner of a photo. 我在照片的右上角有一个相对位置的“删除”图标。 When the icon is clicked, the photo should be deleted on the server. 单击图标后,应在服务器上删除照片。
According to HTTP conventions, this is a destructive action which should be done with POST. 根据HTTP约定,这是应该使用POST进行的破坏性操作。 So a normal <img href>
can not be used since it will cause a GET, which is more insecure. 因此,不能使用常规的<img href>
因为它会导致GET的出现,因此更加不安全。
What is the simplest way to make the icon perform a POST that does not exclude Internet Explorer 8? 使图标执行不排除Internet Explorer 8的POST的最简单方法是什么? I am currently looking at: 我目前正在查看:
<form method="post" action="script.php">
<img src="photo.jpg"/>
<input name="delete" type="image" src="/image/delete.png"/>
</form>
Or, is it acceptable to use a href
in this situation? 或者,在这种情况下使用href
是否可以接受?
(EDIT: Is it more acceptable when the script is only available to an authenticated administrator? ) (编辑:当脚本仅对经过身份验证的管理员可用时,是否可以接受? )
you should use this code 您应该使用此代码
<form method="post" action="script.php">
<button type="submit" style="background:photo.jpg"/>
<input name="delete" type="image" src="/image/delete.png"/>
</form>
so you can use your photo as background,because when you want submit a form you shold have a input or button whith type submit 这样您就可以将照片用作背景,因为当您要提交表单时,您需要输入或提交类型的按钮
<button type="submit" name="testsubmit" value="click"
style="border:none; background-color:transparent;">
<img src="button.png" alt="test image submit" />
</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.