Click here to Skip to main content
15,905,874 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear Friends,

am working on Visual studio 2008 using Asp.net c#.

I want to Upload a PDF file in folder with name AttachmentsTIS (Which is in Solution Explorer).

The Name of Attachments folder is AttachementsTIS

Just I want to upload this pdf file in already existing record by using Id. So am using UPDATE command for this.

So already i wrote code for this, but it is unable to upload in AttachmentsTIS folder.

This is my UPDATE button code.
-------

protected void btnUpdate_Click(object sender, ImageClickEventArgs e)
{
SqlConnection conUpdate = new SqlConnection(_connString);
SqlCommand cmdUpdate = new SqlCommand();
cmdUpdate.Connection = conUpdate;
cmdUpdate.CommandText = "UPDATE AccountsInfo SET Requestor_Name='" + TxtRequestorName.Text + "', Attachment='" + FileUploadTurnInRequest.FileName + "', "' Where Id = '" + Request.QueryString["Id"] + "'";
using (conUpdate)
{
conUpdate.Open();
cmdUpdate.ExecuteNonQuery();
conUpdate.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "RunCode", "javascript:alert('Submitted Successfully');window.close(),document.location.href="/KB/answers/Home.aspx";", true);
}
}


Please help me, check the query once.

Thanks.
Posted
Updated 26-Aug-13 0:52am
v3
Comments
Neema Derakhshan 27-Aug-13 0:23am    
where in code did you try to save the pdf in AttachmentsTIS folder ?!

hi

use like this

fileUpload.PostedFile.SaveAs(Server.MapPath("Upload/" + filePath));

hope this will help
 
Share this answer
 
Comments
Ranjith Reddy CSE 26-Aug-13 7:04am    
Sorry, this is not working. Please can you write in my query.
Ranjith Reddy CSE 26-Aug-13 7:56am    
anybody frds, please help me this task.
thanks.
this code will save your file (pdf) in the folder
put your solution's folder address in MapPath
C#
string savePath = MapPath("~/.../AttachmentTIS/" + ... + fileUpload.FileName);

if (fileUpload.HasFile)
{
   fileUpload.SaveAs(savePath);
}
 
Share this answer
 
try this.
using a file uploader asp control:

C#
private void StartUpLoad()
   {
       string fname = ".pdf";
       string chepar = TextBox1.Text + fname; //TextBox1.Text is the file name
       string pdfPath = "PDFFOLDER/" + chepar;
       string punta = "~/" + pdfPath;

   FileUpload1.SaveAs(Server.MapPath(pdfPath));


    }
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900