In this i would like to explain about upload pdf and view, using file upload control .
here i will explain already we studied about upload control in previous chapter.
So
code in .aspx page:
<form>
<div>
Upload:<asp:FileUpload runat="server" ID="fileUpload" />
<br />
<asp:Button ID="Button1" runat="server" Text="Upload" OnClick="FileUpload_Click" />
<asp:HyperLink runat="server" ID="lnkButton" Text="View File" />
</div>
</form>
code in .aspx.cs page:
Add name space using sytem .IO;
//code in button click event.
Add folder in solution explorer Resumes
protected void FileUpload_Click(object sender, EventArgs e)
{
if (fileUpload.HasFile)
{
string strpath = "~/Resumes" + fileUpload.FileName;
fileUpload.SaveAs(Server.MapPath(strpath));
lnkButton.NavigateUrl = "~/Resumes/" + fileUpload.FileName;
//This link button redirects to our resume folder and display the pdf file.
Response.Write("<script>alert('uploaded successfully');</script>");
}
So your pdf is uploaded here and if you click on view file then it show your pdf file formate.
maximum size for uploading a pdf file is 4096 i.e, 4mb only.
you will specify the size limit in web config file.
In <system.web> tag
system.web>
<httpRuntime executionTimeout="90" maxRequestLength="16834" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
enableVersionHeader="true" />
(4096 for 4mb it is default,8192 for 8mb,16384 for 16 mb, 65536 for 64 mb .............
I hope you understand .
maximum size for uploading a pdf file is 4096 i.e, 4mb only.
you will specify the size limit in web config file.
In <system.web> tag
system.web>
<httpRuntime executionTimeout="90" maxRequestLength="16834" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
enableVersionHeader="true" />
(4096 for 4mb it is default,8192 for 8mb,16384 for 16 mb, 65536 for 64 mb .............
I hope you understand .
if you get any queries about this post a comment.