1

I trying to implement the demo that is on the www.dropzonejs.com site but i am having trouble doing what it is supposed to. I will be connecting it to a database so i can send a copy of the uploaded file info to the database. Has anyone done a clear tutorial with this in asp.net c#? How can i control what i have so once a file has been dropped in the area i will fire up the method for database connections?

html:

  <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="~/Scripts/dropzone.js"></script>
    <link href="~/Content/dropzone.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form class="dropzone dz-clickable">
        <div class="dz-default dz-message">
            <span>DRAG & DROP FILES HERE</span>
        </div>
    </form>
</body>
</html>

Tried this from another stackoverflow post but not sure it is doing anything it is not passing into the foreach loop:

 protected void Page_Load(object sender, EventArgs e)
        {
            foreach (string s in Request.Files)
            {
                HttpPostedFile file = Request.Files[s];

                int filesSizeInBytes = file.ContentLength;
                string fileName = Request.Headers["X-File-Name"];
                string fileExtension = "";

                if (!string.IsNullOrEmpty(fileName))
                    fileExtension = Path.GetExtension(fileName);

                string savedFileName = Path.Combine(@"C:\temp\", Guid.NewGuid().ToString() + fileExtension);
                file.SaveAs(savedFileName);
            }
        }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Masriyah
  • 2,445
  • 11
  • 49
  • 91
  • @Slaks I posted what i found on a previous post on stackoverflow but i am not sure it is doing anything. I am looking more to how i could control what i do with the file after it has been processed or ready for upload – Masriyah Jul 10 '13 at 17:49
  • So are you actually asking how to save an `HttpPostedFile` to SQL Server? – SLaks Jul 10 '13 at 17:59
  • @SLaks yes how can i connected the file being uploaded to database – Masriyah Jul 10 '13 at 18:16

1 Answers1

0

Update

If I am not mistaken, the upload is done, the file saved in temp directory as savedFileName.

Using dropzone.js in asp.net

AngularJs, DropZone.Js, MVC4 - Drag, Drop and Preview pre-Uploaded Image(s)

The next step is stored in the database. The saved files (in temp directory) to be stored in the SQL database. This is what the articles:

  1. If you have MS SQL, then a good option is to filestream: upload filestream data from aspnet.
  2. Another a good option is to fileTable.
  3. The 3. option is to Azure blob.
Community
  • 1
  • 1
Gábor Plesz
  • 1,203
  • 1
  • 17
  • 28
  • thanks, i wanted to know about the actual handling process with dropzone. i am having trouble of where could i control a file being uploaded – Masriyah Jul 11 '13 at 13:12