hi,
i convert the file to a byte array and then upload to a server,when i performing this i have an error.
(i.e)
Error 1 : System.Byte[]Error: Could not find a part of the path 'D:\Karthi\fileupload1\Data\System.Byte[]'.
Error 2: Could not find file 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\abs.doc'.
These two error will occur how can i solve this,
Here i attached the codings.
Loading

Krishna GaradRank #191 · 12.8K reputationPosted Jan 27, 2011, 1:52 AM EST
krithika muthukrishnanRank #8,369 · 223 reputationPosted Jan 27, 2011, 3:19 AM EST
Here i attached coding for upload the file to a server.is this correct or not
codings :
if (FileUpload1.HasFile)
{
try
{
FileUpload1.SaveAs("C:\\Uploads\\" + FileUpload1.FileName);
Label1.Text = "File name: " +FileUpload1.PostedFile.FileName }
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "You have not specified a file.";
}
}
Krishna GaradRank #191 · 12.8K reputationPosted Jan 27, 2011, 6:17 PM EST
string virtualFolder = "~/Upload/";
string physicalFolder = Server.MapPath(virtualFolder);
FileUpload1.SaveAs(physicalFolder + FileUpload1.FileName);
It will upload file to server. For this you need to create Folder in root directory of your application as "Upload".
krithika muthukrishnanRank #8,369 · 223 reputationPosted Jan 27, 2011, 6:49 PM EST
i want the clear explanation about server.mappath();
thank you
Krishna GaradRank #191 · 12.8K reputationPosted Jan 27, 2011, 6:58 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Jan 28, 2011, 12:08 AM EST
Lots of articles here about Server.MapPath (even i replied your same post two days ago) and File upload.
How to Upload Files in ASP.NET
File Uploading in ASP.NET 2.0
Suthish NairRank #92 · 22.8K reputationPosted Jan 30, 2011, 8:24 AM EST
So other members can easily find the answers.