volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 506 forks source link

upload multiple files through Dialog #1327

Open Sz2014 opened 10 years ago

Sz2014 commented 10 years ago

am trying to add filed to upload multiple files using the Dialog

I added that already and I can see the uploaded files field but it dosnet upload the files. what am doing wrong?

image of the Dialog:

s

here the code :

               UplodedFiles: {
                title: 'Uploded Files',
                type: 'file',
                input: function (data) {
                return '<form target="iframeTarget" class="formUploadFile"  action="Upload" method="post" enctype="multipart/form-data"> <input type="file" onchange="this.form.submit()" name="myFile"/> </form> <iframe class="upload-iframe" style="display: none;" src="#" name="iframeTarget"></iframe>';
                },

My Action Methoed:

                     [HttpPost]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Upload()
{
    string upload_dir = Server.MapPath("~/app_data/Uploded/");

    foreach (string f in Request.Files.Keys)
    {
        if (Request.Files[f].ContentLength > 0)
        {
            //System.IO.File.SetCreationTime(Server.MapPath("~/App_Data/Uploded/" + Request.Files[f].FileName), DateTime.Now);
            Request.Files[f].SaveAs(upload_dir + System.IO.Path.GetFileName(Request.Files[f].FileName));

            //Project.UplodedFiles += Request.Files[f].FileName + '#';
            //_db.Entries.Add(Project);
            //_db.SaveChanges();
        }
    }

    return RedirectToRoute(new { Action = "Index", Controller = "Projects" });
}
denhsieh commented 9 years ago

Did you ever figure this out? I'm trying to implement something like this