TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shibly Sadik
NA
167
138.6k
Error while uploading file after deployment
Aug 13 2015 1:27 AM
I have uploaded my MVC application on appharbor for testing purpose yesterday.But after deployed,when i try to upload images from my computer it is showing me the following error:
System.UnauthorizedAccessException: Access to the path 'D:\Users\apphb2f0ef12b414003\app\_PublishedWebsites\N_Commerce\Images\s-l50010.jpg' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at System.Web.HttpPostedFileWrapper.SaveAs(String filename) at N_Commerce.Controllers.HomeController.Upload_Sample_Product(SampleProduct product, HttpPostedFileBase file) in d:\temp\btjpm4su.3lh\input\N_Commerce\Controllers\HomeController.cs:line 43
Here is my controller:
[HttpPost]
public ActionResult Upload_Sample_Product(SampleProduct product, HttpPostedFileBase file)
{
try
{
if (ModelState.IsValid)`
{
if (file != null)
{
var extension = Path.GetExtension(file.FileName);
file.SaveAs(HttpContext.Server.MapPath("~/Images/") + file.FileName);
product.Image = file.FileName;
}
db.SampleProducts.Add(product);
db.SaveChanges();
return RedirectToAction("ProductView");
}
}
catch (Exception ex)
{
return Content("" + ex);
}
return View();
}
I have given permission(NETWORK SERVICE) to the folder where the images are stored.But still it is not working.
Reply
Answers (
4
)
how to create custom text editor as a custom control
How To Show The .docx file in Html page