使用此代码浏览后,如何在我的表单上显示图像? [英] How to display image on my form after browsing for it using this code?
问题描述
大家好
我正在使用这段代码来浏览图片。现在,如果有人知道 如何在浏览后在我的表单上显示图像 它使用此代码?
P.S。我不希望图像上传到服务器只是为了显示在用户的页面上
< input id =" fileInput"类型= QUOT;文件"风格= QUOT;显示:无;" />
< input type =" button" value ="选择文件!的onclick = QUOT;的document.getElementById("的FileInput")点击();" />
我的意思是以下编码的字形
Dim ofd New OpenFileDialog
ofd.AddExtension = True
ofd.CheckFileExists = True
ofd.CheckPathExists = True
ofd.Filter =" Image Files | * .jpg; * .bmp; * .PNG; *&GIF QUOT。
ofd.FilterIndex = 1
ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
ofd.Multiselect = True
ofd.RestoreDirectory = True
ofd.Title ="选择要添加到列表中的文件"
如果ofd.ShowDialog()= DialogResult.OK然后
PictureBox1.Image = Image.FromFile(ofd.FileName)
结束如果
谢谢高级,我非常感谢任何帮助。
< img> 元素的
src 属性可以设置为指向服务器上的图像文件。
访问下一个地方:
- https://forums.asp.net
- https://forums.asp.net/t/1478425.aspx?Upload+ file + from + client + to + server
Hi all
I am using this piece of code to browse for image. And now if any one know How to display image on my form after browsing for it using this code?
P.S. I do't want image to upload to server just to be displayed on user's page
<input id="fileInput" type="file" style="display:none;" /> <input type="button" value="Choose Files!" onclick="document.getElementById('fileInput').click();" />
What I meant is simillar to the the following coded
Dim ofd As New OpenFileDialog ofd.AddExtension = True ofd.CheckFileExists = True ofd.CheckPathExists = True ofd.Filter = "Image Files|*.jpg;*.bmp;*.png;*.gif" ofd.FilterIndex = 1 ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop ofd.Multiselect = True ofd.RestoreDirectory = True ofd.Title = "Select the files that you want to add to the the list" If ofd.ShowDialog() = DialogResult.OK Then PictureBox1.Image = Image.FromFile(ofd.FileName) End If
Thanks advanced and I really appreciate any help
I think that the image has to be transferred (uploaded) to the server. Then the src attribute of an <img> element can be set to point to the image file on the server.
Visit the next places:
这篇关于使用此代码浏览后,如何在我的表单上显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!