Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the code is given below

view
---------
Razor
@{
    ViewBag.Title = "Index";
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Upload Files</title>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.min.js")"></script>
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Uploadify/uploadify.css")" />

    <script type="text/javascript">
        $(function () {
            $('#file_upload').uploadify({
                'swf': "@Url.Content("~/Content/Uploadify/uploadify.swf")",
                'cancelImg': "@Url.Content("~/Content/Uploadify/uploadify-cancel.png")",
                'uploader': "@Url.Action("Upload", "Home")",
                'onUploadSuccess': function (file, data, response) {
                    $("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />");
                }
            });
        });
    </script>

</head>
<body>
    <div>
        Click Select files to upload files.
        <input type="file" name="file_upload" id="file_upload" />
    </div>
    <div id="uploaded">
    </div>
</body>
</html>



controller
-----------
C#
public ActionResult Upload()
      {
          var file = Request.Files["Filedata"];
          string savePath = Server.MapPath(@"~\Content\" + file.FileName);
          file.SaveAs(savePath);

          return Content(Url.Content(@"~\Content\" + file.FileName));
      }


pls help me
thanks in advance
Posted
Updated 18-Nov-15 21:47pm
v2
Comments
Krunal Rohit 19-Nov-15 4:06am    
Any error in browser console ?

-KR
Athul MS 19-Nov-15 4:09am    
in console there is an error TypeError: $(...).uploadify is not a function
Anil Sharma1983 19-Nov-15 4:21am    
http://forums.asp.net/t/1927821.aspx?Jquery+file+upload+using+uploadify Please check this link

1 solution

<script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.min.js")"></script>


Instead of adding these two script just use only one script . It seems that
your code doesn't find the definition of uploadify.So add only the minified version
just before
<script type="text/javascript">
$(function () {
$('#file_upload').uploadify({
'swf': "@Url.Content("~/Content/Uploadify/uploadify.swf")",
'cancelImg': "@Url.Content("~/Content/Uploadify/uploadify-cancel.png")",
'uploader': "@Url.Action("Upload", "Home")",
'onUploadSuccess': function (file, data, response) {
$("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />");
}
});


And Your Jquery script also
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900