我已将文件上传到名为 quiz 的文件夹并使用
server_filepath = Server.MapPath(folderName) + "\\" + fileName;
fileUpload.PostedFile.SaveAs(server_filepath);
cmd.CommandText = "Insert Into quiz(description) Values('" + server_filepath + "')";
并将上传文件的链接保存到数据库。
该链接在另一个页面中显示为。
<asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="HyperLink"
DataSourceID="SqlDataSource1" DataTextField="description"
DataValueField="id">
</asp:BulletedList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:chaaapaConnectionString4 %>"
SelectCommand="SELECT * FROM [quiz]"></asp:SqlDataSource>
但是当点击链接时会发生错误,即找不到资源。