我正在尝试使用带有 Visual Studio 2008 的 vb.net 和 asp.net 开发一个带有文件上传和下载选项的网站。任何人都可以帮助我了解如何提供将文件上传到服务器然后提供下载链接的功能将可供普通用户从服务器下载文件。提前致谢。
问问题
22937 次
3 回答
2
使用 FileUpLoad 控件。这是一个上传示例(在 c# 中): http ://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx
于 2012-10-27T15:41:49.387 回答
1
您可以使用asp:FileUpload
控件将文件上传到您的服务器,该位置具有写入文件的权限
就像将控件放在.aspx
文件中一样简单
<asp:FileUpload runat="server" ID="MyFileUpload" />
代码隐藏
If (MyFileUpload.HasFile) Then
MyFileUpload.SaveAs('the full path to directory ' & filename)
End If
您可以将文件描述及其路径存储在数据库中,在您的页面上检索并显示给用户
您还可以浏览目录并列出页面上的文件
于 2012-10-27T15:38:22.557 回答
-1
将 FileToCopy 调暗为字符串
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 If
于 2013-08-18T11:45:34.750 回答