小白有问题:如何将图片路径写入access 多谢了
Partial Class Default3
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsPostBack Then
Dim path As String = Server.MapPath("~/UploadedImages/")
Dim fileOK As Boolean = False
If FileUpload1.HasFile Then
Dim fileExtension As String
fileExtension = System.IO.Path. _
GetExtension(FileUpload1.FileName).ToLower()
Dim allowedExtensions As String() = _
{".jpg", ".jpeg", ".png", ".gif"}
For i As Integer = 0 To allowedExtensions.Length - 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
If fileOK Then
Try
FileUpload1.PostedFile.SaveAs(path & _
FileUpload1.FileName)
Label1.Text = "File uploaded!"
Catch ex As Exception
Label1.Text = "File could not be uploaded."
End Try
Else
Label1.Text = "Cannot accept files of this type."
End If
End If
End If
End Sub
Partial Class Default3
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsPostBack Then
Dim path As String = Server.MapPath("~/UploadedImages/")
Dim fileOK As Boolean = False
If FileUpload1.HasFile Then
Dim fileExtension As String
fileExtension = System.IO.Path. _
GetExtension(FileUpload1.FileName).ToLower()
Dim allowedExtensions As String() = _
{".jpg", ".jpeg", ".png", ".gif"}
For i As Integer = 0 To allowedExtensions.Length - 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
If fileOK Then
Try
FileUpload1.PostedFile.SaveAs(path & _
FileUpload1.FileName)
Label1.Text = "File uploaded!"
Catch ex As Exception
Label1.Text = "File could not be uploaded."
End Try
Else
Label1.Text = "Cannot accept files of this type."
End If
End If
End If
End Sub
解决方案 »
- VB6莫名其妙的问题,折腾死人
- 跪求 VB 将SQL表导出成excel文件 和 将excel导入到SQL表中
- 求救!!!帮帮忙解决一下!!!!
- 请问如何用OLE删除EXCEL工作簿中的某张表,该怎么写啊?
- vb6对窗体数有限制嘛?
- 高分請教:怎樣讀寫網站上的Access數據?
- 如何快速获取DataGrid内第一条记录和最后一条记录里面的某个字段的值.(100分)
- 好消息,进销存源代码(试用版请到ftp://61.145.209.186/下载)!
- 很简单的问题,枪分罗
- 急!在线等,如何在客户端通过Http访问SQL数据库的问题?
- 求助SHGetPropertyStoreForWindow
- 新手自学VB6,代码出现问题请教
rs1.fields(?)="图片所在的全路径包含文件名称与扩展名"
rs1.update这样就可以啦,如果字段长度不够肯定将报错,记住路径如果包含汉字的话,一个汉字占两个字符的长度。要节省空间的话 文件夹路径固定下来,数据库只要保存文件名称带扩展名即可。