如何选择图像并将图像的链接放在文本框中


How can I select an image and put the link of the image in a textbox?

我有一个表单SelectIamge.php其中包含以下html:

<input type="text" id="urlImage" />
<input type="button" id="selectImage" />

用户需要能够单击选择图像按钮以打开页面 UploadImage.php 的弹出窗口。然后,用户将上传图像,并显示该图像的缩略图。如果用户单击缩略图,我需要将图像的 url 放在 urlImage 文本框中。

有人可以帮我解决这个问题吗?

首先给缩略图一些id,即id='thumb'

包含 jquery 库文件并在文件中写入下面的 javascript

<script type="text/javascript">
$("#thumb").click(function(){
   var src = $(this).attr('src');
   $("#urlImage").val(src);
});
</script>