i have uploaded a file to folder named quiz and save it using
server_filepath = Server.MapPath(folderName) + "\\" + fileName;
fileUpload.PostedFile.SaveAs(server_filepath);
cmd.CommandText = "Insert Into quiz(description) Values('" + server_filepath + "')";
and save the link of uploaded file to database.
that link is displayed in another page as.
<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>
but when click on the link the error occurs
that is the resource cannot be found.
You’re saving an absolute path (C:\inetpub\wwwroot\yoursite\quiz\filename.pdf) to the database.
Try saving Path.Combine(folderName, fileName) to the database, and use that as the hyperlink instead.