Reputation: 11
I want to upload mp3 file using file uploader and I don't want to save it in the database I used server.mappath
if (FileUploadsong.HasFiles)
{
FileUploadsong.PostedFile.SaveAs(Server.MapPath("songs" + "/" + Txtsongname + "~/mp3file/"));
byte[] mp3file = System.IO.File.ReadAllBytes("songs");
}
but I got this error:
Upvotes: 0
Views: 811
Reputation: 23937
The error tells you that you path name is invalid and cannot be found.
That is, because you are using the control itself as part of your path, instead of its .Text
property:
if (FileUploadsong.HasFiles)
{
FileUploadsong.PostedFile.SaveAs(Server.MapPath("songs" + "/" + Txtsongname.Text + "/mp3file/"));
byte[] mp3file = System.IO.File.ReadAllBytes("songs");
}
And please, post your errors as text, not as an image. Screenreaders cannot interpret images and if the image does get deleted, so does your error message for everyone.
Upvotes: 4