Using Jquery Uploadify, I am not able to pass the file to the controller.
View :
<input type="file" name="file_upload" id="file_upload" />
Jquery:
<script type="text/javascript">
$(function () {
var uploadUrl = $('#file_upload').data();
$('#file_upload').uploadify({
'auto': true,
'script': uploadUrl,
'swf': 'Uploadify/uploadify.swf',
'uploader': '/ControllerName/Upload',
'debug': true
});
});
</script>
Controller
[HttpPost]
public string Upload(HttpPostedFileBase file)
{
//"file" = null is being passed from the view to the controller.
//code..
}
I am missing something, Thanks for your help.
You can use:
or
If neither of these are working and your action isn’t firing at all (i.e. try debugging and see if a breakpoint within the method is hit), then your issue is most likely the ‘script’ value – are you running under a virtual directory? If so you’ll need to put the name of the directory in front. Uploadify is using an absolute path.
You may also want to check the swf path,
swf': 'Uploadify/uploadify.swf'. The way it is configured, it is relative to the current page. So if you were on localhost/Somepage it would be looking for /Somepage/Uploadify/uploadify.swf. You can check the browsers Network tab to ensure the uploadify.swf is not a404