I am trying to use Uploadify plugin to allow user add his files to server, but in the controller action it returns null. I reserched posts, forums, tryed a lot of things, but still the same problem. I'll post my code, maybe you'll see or know what i don't:
Thanks a lot for the reply. I've already solved this one. The point was that the parametr in the controller method need to have the strict name - fileData.
Marked as answer by BU XI - MSFT on Feb 07, 2012 02:06 AM
Musya
Member
60 Points
29 Posts
Uploadify returns null
Feb 02, 2012 10:50 AM|LINK
Hi everyone!
I am trying to use Uploadify plugin to allow user add his files to server, but in the controller action it returns null. I reserched posts, forums, tryed a lot of things, but still the same problem. I'll post my code, maybe you'll see or know what i don't:
<script src="@Url.Content("~/Scripts/jquery-1.4.2.min.js")" type="text/javascript"></script><script src="@Url.Content("~/Scripts/jquery.uploadify.v2.1.4.min.js")" type="text/javascript"></script><script src="@Url.Content("~/Scripts/swfobject.js")" type="text/javascript"></script><link href="@Href("~/Content/uploadify.css")" rel="stylesheet" />
<input id="fileuploader" name="fileuploader" type="file" />
<script type="text/javascript">
$(document).ready(function () {
$('#fileuploader').uploadify({
'uploader': '/Scripts/uploadify.swf',
'script': '@Url.Content("~/Home/About")',
'cancelImg': '/Content/cancel.png',
'auto': true,
'multi': false,
'buttonText': 'Select image',
'fileDesc': 'Images (.JPG)',
'fileExt': '*.jpg;',
'sizeLimit': 1024000
}); });</script>
public void About(HttpPostedFileBase file) {
var files = Request.Files;
if (file != null)
{ string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/"; string filename = Path.GetFileName(file.FileName);
if (filename != null) file.SaveAs(Path.Combine(path, filename));
}
}
What's wrong? Thanks in advance.
<div></div>karthic_85
Contributor
2598 Points
587 Posts
Re: Uploadify returns null
Feb 02, 2012 01:51 PM|LINK
you need to write a handler (.ashx) & use code provided in http://www.technowise.in/2009/12/uploadify-aspnet-c-vb-examples-demo.html
Musya
Member
60 Points
29 Posts
Re: Uploadify returns null
Feb 02, 2012 01:57 PM|LINK
Thanks a lot for the reply. I've already solved this one. The point was that the parametr in the controller method need to have the strict name - fileData.