如何在VB.NET中上传图片 [英] How to upload image in VB.NET

查看:114
本文介绍了如何在VB.NET中上传图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想上传员工图像并将其保存到数据库.
请告诉我该怎么做..

Hi all

i want to upload employee image and save it to database.
please tell me how to do that..

推荐答案

您是否尝试过 ^ ].简单的搜索可以使用许多替代解决方案轻松解决您的问题.请先尝试Snehasish.

查看此代码:
Have you tried googlin??[^]. A simple search can easily solve your problem with lots of alternative solutions. Try it first Snehasish.

Check out this code:
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If Not fileUpEx.HasFile Is Nothing Then

Dim filepath As String = fileUpEx.PostedFile.FileName
Dim pat As String = "\\(?:.+)\\(.+)\.(.+)"
Dim r As Regex = New Regex(pat)
'run
Dim m As Match = r.Match(filepath)
Dim file_ext As String = m.Groups(2).Captures(0).ToString()
Dim filename As String = m.Groups(1).Captures(0).ToString()
Dim file As String = filename & "." & file_ext

'save the file to the server 
fileUpEx.PostedFile.SaveAs(Server.MapPath(".\") & file)
lblStatus.Text = "File Saved to: " & Server.MapPath(".\") & file

End If
End Sub


有用的链接可以做到这一点-
http://www.codeproject.com/Articles/437937/Save-and-Retrieve-Image-from-a-SQL-Server-Database
Useful Link to do that-
http://www.codeproject.com/Articles/437937/Save-and-Retrieve-Image-from-a-SQL-Server-Database


这篇关于如何在VB.NET中上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆