Sir,
What is the code for uploading images into server map path?
Thanks regards
jahi
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Jun 28, 2011, 8:51 PM EDT
string virtualFolder = "~/FolderName/";
string physicalFolder = Server.MapPath(virtualFolder);
FileUpload1.SaveAs(physicalFolder + FileUpload1.FileName);
jaheena jamal75 reputationPosted Jun 28, 2011, 9:09 PM EDT
below code is in my page. but error has occured.
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
string SaveLocation = Server.MapPath("image") + "\\" + fn;
try
{
File1.PostedFile.SaveAs(SaveLocation);
Response.Write("The file has been uploaded.");
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}
else
{
Response.Write("Please select a file to upload.");
}
But the error is "Error: Access to the path '--------- ' is denied.
what is the reason for this?
Krishna GaradRank #191 · 12.8K reputationPosted Jun 28, 2011, 9:16 PM EDT
jaheena jamal75 reputationPosted Jun 28, 2011, 9:27 PM EDT
i tried the code above that you give, but same error displayed.
Krishna GaradRank #191 · 12.8K reputationPosted Jun 28, 2011, 9:32 PM EDT
jaheena jamal75 reputationPosted Jun 28, 2011, 9:36 PM EDT
Krishna GaradRank #191 · 12.8K reputationPosted Jun 28, 2011, 9:39 PM EDT
jaheena jamal75 reputationPosted Jun 28, 2011, 9:41 PM EDT
Krishna GaradRank #191 · 12.8K reputationPosted Jun 28, 2011, 9:44 PM EDT
jaheena jamal75 reputationPosted Jun 28, 2011, 9:57 PM EDT