views:

351

answers:

3

First of all, I've checked out all the SO threads, and googled my brains out. I must be missing something obvious. I'd really appreciate some help! This is what I've got.

UploadController.cs

using System.Web;
using System.Web.Mvc;

namespace NIMDocs.Controllers
{
    public class UploadController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }


        public string Processed(HttpPostedFileBase FileData)
        {
            // DO STUFF

            return "DUHR I AM SMART";
        }

    }
}

Index for Upload

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ITS A TITLE </title>
    <script src="../../Content/jqueryPlugins/uploadify/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../Content/jqueryPlugins/uploadify/swfobject.js" type="text/javascript"></script>
    <script src="../../Content/jqueryPlugins/uploadify/jquery.uploadify.v2.1.0.min.js" type="text/javascript"></script>


<script type="text/javascript">
    $(document).ready(function () {
        $('#uploadify').fileUpload({
            'uploader': '../../Content/jqueryPlugins/uploadify/uploadify.swf',
            'script': '/Upload/Processed',
            'folder': '/uploads',
            'multi': 'true',
            'buttonText': 'Browse',
            'displayData': 'speed',
            'simUploadLimit': 2,
            'cancelImg': '/Content/Images/cancel.png'
        });
    });
</script>
</head>
<body>
<input type="file" name="uploadify" id="uploadify" />
<p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p>
</body>

    </html>

What am I missing here? I've tried just about every path permutation for uploadify's "uploader" option. Absolute path, '/' prefixed, etc.

This is what I'm seeing. alt text

And here is the directory structure. alt text

+3  A: 
Nicholas Murray
Good catch, but I'm still not having any luck. I've added some edits that may help to my original post.Thanks
Paperino
Try the edit above - works fine for me (can see the uploaded file in newFile)public string Processed(HttpPostedFileBase FileData) { HttpPostedFileBase newFile = FileData; return "DUHR I AM SMART"; }
Nicholas Murray
Awesome. What exactly was i doing wrong? The trailing ]]> ? I cannot thank you enough. I do have another quick question for you if you don't mind... is uploadify actually uploading the document to /uploads? If so, where is it on the local directory?
Paperino
public string Processed(HttpPostedFileBase FileData) { HttpPostedFileBase newFile = FileData; FileData.SaveAs(@"c:\Temp\" + FileData.FileName); return "File Saved"; }or you could use in conjunction with something like var path = HostingEnvironment.MapPath("folders");
Nicholas Murray
+2  A: 

Your spelling of "Processed" varies between the javascript call (Processed) and the method definition (Procssed). Is that incidental?

Nathan Taylor
yes actually that is incidental. I've changed the controller names so many times that one got past me.
Paperino
A: 

I am not sure, but in classic ASP ASP.net webforms, the form enctype had to be set to multipart/form-data

<form enctype='multipart/form-data'>
 <input type='file'>
 <input type='Submit'>
</form>
ggonsalv