II have an asp.net form with a FileUpload function. This section is working correctly:
protected void UploadCertificate(object sender, EventArgs e)
{
if (quality_certificate.HasFile)
{
string fileName = quality_certificate.FileName;
quality_certificate.SaveAs(MapPath("fileuploads/" + fileName));
LabelQC.Text = "File " + fileName + " has uploaded";
}
else
{
LabelQC.Text = "No file uploaded";
}
}
However when I try to retreive this file on submitting the form, it will not attach to the email presumably because the MapPath line is incorrect? Any advice welcome!
Attachment attachFile = new Attachment(Server.MapPath("fileuploads/" + quality_certificate.FileName));
For example when its hard coded it works:
Attachment attachFile = new Attachment(Server.MapPath("fileuploads/logo.gif"));// THIS WORKS
The directory is fileuploads within the root of the web site.
Permissions set to 775.
identity impersonate="true"
" quality_certificate.SaveAs
But when you try to download this file you use
"Attachment attachFile = new Attachment(Server.MapPath(
it is better to use " fileName" in the place of "quality_certificate.FileN
because some time string "quality_certificate" dose not found due to protected class.