问题:无法使用FilePath显示图像
我有文件上传按钮,捕获文件路径&当我点击上传按钮,它应该显示我所选择的图像。但这并没有发生?
我错过了什么?我需要将路径转换为图像url吗?如果是,请提供背后的代码给我??
Thanks in advance.
这是我的代码....
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim path As String
path = Server.MapPath(FileUpload1.FileName)
Image1.ImageUrl = path
Label1.Text = Image1.ImageUrl
End Sub
您忘记保存文件了?
FileUpload1.SaveAs(string SomeFileNameOnServer)
也应该发生,在您从服务器显示之前。
(不确定上面这行在VB.NET中是怎么写的)
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim path As String
path = Server.MapPath("~/.") + FileUpload1.FileName;
FileUpload1.SaveAs(path)
Image1.ImageUrl = path
Label1.Text = Image1.ImageUrl
End Sub