Which is the file I'm trying to upload. We are using the Development Server on Windows 7 x64 Edition (if that could be part of the problem)
I don't think that could be the problem, I would suggest to build a seperate project just with form post and action method, possibly you can copy the code given here and see if it works.
BackOffice is the Controller name, and UploadImage is the Method name on that Controller.
'Stephanie is my daugters name and I'm using her memberName for testing purposes. But as you can see, that is not anywhere on the @Html.BeginForm(...) statement. So where is that coming from???
eric2820
Contributor
2777 Points
1161 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 03:25 PM|LINK
Fiddler shows in it's Web Forms Inspector view:
file eirc.jpg
Upload Upload
Which is the file I'm trying to upload. We are using the Development Server on Windows 7 x64 Edition (if that could be part of the problem)
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
CPrakash82
All-Star
18314 Points
2851 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 04:11 PM|LINK
I don't think that could be the problem, I would suggest to build a seperate project just with form post and action method, possibly you can copy the code given here and see if it works.
http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx
eric2820
Contributor
2777 Points
1161 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 06:06 PM|LINK
Where did you think I was getting that code from in the first place? I already had that site you mentioned open :-)
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
eric2820
Contributor
2777 Points
1161 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 06:12 PM|LINK
This is from the View Source on the page that I'm trying to get working:
<!DOCTYPE html>
<html>
<head>
<title>My-MSI.Net | Back Office | Upload Image</title>
<link href="/Content/BackOffice.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-validate.min.js" type="text/javascript"></script>
</head>
<body>
<div class="menu">
<h1>- Back Office | Menu </h1>
<p>
<h2><a href="/BackOffice/Index/Stephanie">Home</a></h2></p>
<p>
<h2><a href="/BackOffice/UploadImage/Stephanie">UploadImage</a></h2></p>
<p>
<h2><a href="/BackOffice/Twitter/Stephanie">Twitter</a></h2></p>
</div>
<div class="content">
<h2>Upload Image</h2>
<form action="/BackOffice/UploadImage/Stephanie?method=post&enctype=multipart%2Fform-data" method="post">
<table style="width: 75%">
<tr>
<td align="right">
File to Upload:
</td>
<td align="left">
<input type="file" name="file" value="Browse" />
</td>
</tr>
</table>
<input type="submit" name="Upload" value="Upload" />
</form>
</div>
<div style="clear: both; height: 1px; margin-top: -1px;"></div>
<div style="height: 2in; background-color: Transparent"></div>
</body>
</html>
Everything looks right to me, so unless someone tells me where the problem is, I won't be able to find it.
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
CPrakash82
All-Star
18314 Points
2851 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 06:40 PM|LINK
Are you really sure that copied the code from that post? Anyway here is your problem.
Ideally you should have form tag like below
<form action="[controller/action]" method="post" enctype="multipart/form-data">
Looks like you are using the wrong overload and may be specifying the wrong parameter.
eric2820
Contributor
2777 Points
1161 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 07:31 PM|LINK
This is what is in the UploadImage view:
@using ( @Html.BeginForm( "UploadImage", "BackOffice", new { method = "post", enctype = "multipart/form-data" } ) )
BackOffice is the Controller name, and UploadImage is the Method name on that Controller.
'Stephanie is my daugters name and I'm using her memberName for testing purposes. But as you can see, that is not anywhere on the @Html.BeginForm(...) statement. So where is that coming from???
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
eric2820
Contributor
2777 Points
1161 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 08:23 PM|LINK
I see that evertything is being passed as url parameters seperated by '&'
What I don't understand is Why are they being passed this way? and
How can I fix this?
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
CPrakash82
All-Star
18314 Points
2851 Posts
Re: Tying to upload files using MVC 3
Nov 18, 2012 08:40 PM|LINK
This looks different than what you posted earlier. Anyway, it should be changed with this.
@using(Html.BeginForm("UploadImage","BackOffice", FormMethod.Post, new {enctype = "multipart/form-data"}))
Cool, I will leave it on you to figure out where this is coming from.