我正在尝试开发一个网站与文件上传和下载选项使用vb.net和asp.net与Visual Studio2008。谁能帮助我如何提供上传文件到服务器的设施,然后下载链接将可供普通用户从服务器下载文件。提前谢谢。
发布于 2012-10-27 23:41:49
使用FileUpLoad控件。这是一个上传的示例(c#格式):http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx
发布于 2012-10-27 23:38:23
您可以使用asp:FileUpload控件将文件上载到您的服务器,该位置具有写入文件的权限
只需将控件放入.aspx文件中即可
<asp:FileUpload runat="server" ID="MyFileUpload" />代码背后
If (MyFileUpload.HasFile) Then
MyFileUpload.SaveAs('the full path to directory ' & filename)
End If您可以将文件描述与它们的路径一起存储在数据库中,在您的页面上检索并显示给用户
您还可以浏览目录并列出页面上的文件
发布于 2013-08-18 19:45:35
Dim FileToCopy As String
FileToCopy = "F:\fd_demo_limits.swf"
Dim filenameTest = System.IO.Path.GetFileName(FileToCopy)
Dim path As String = "E:\"
Dim filename As String = "communicate.png"
Dim file_ As New System.IO.FileInfo(path + filename)
Dim file_ContentLength As String = "900000" ' check file Length file_.Length = 833740
If (file_.Length > file_ContentLength) Then
MsgBox("file length is large")
Exit Sub
End If
Dim allow_send_pic() As String = {".jpg", ".png", ".gif", "ico", ".png"}
Dim Extension As String = System.IO.Path.GetExtension(filename)
If Array.IndexOf(allow_send_pic, Extension.ToLower()) = -1 Then
MsgBox("File extension not valid")
Exit Sub
End If
If System.IO.File.Exists(FileToCopy) = True Then
While (System.IO.File.Exists(path + filename))
filename = "Copy of " + filename
End While
System.IO.File.Copy(FileToCopy, path + filename)
MsgBox("File Copied")
End Ifhttps://stackoverflow.com/questions/13101546
复制相似问题