File upload in ASP.NET C# Using Dropzone JQuery and JavaScript
Asp.net Image uploading drag and drop with in the DropZone Multiple file Uploading Using JQuery and Javascript without user action.
DEMO
DOWNLOAD
HTML CODING
Database Table
Asp.net Image uploading drag and drop with in the DropZone Multiple file Uploading Using JQuery and Javascript without user action.
DEMO
DOWNLOAD
HTML CODING
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageUpload.aspx.cs" Inherits="ImageUpload" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="DropzoneJs_scripts/jquery.min.js"></script>
<script src="DropzoneJs_scripts/dropzone.js"></script>
<link href="DropzoneJs_scripts/dropzone.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function () {
Dropzone.autoDiscover = false;
var username = $('#<%=lbtUsername.ClientID %>').text().toString();
$("#dZUpload").dropzone({
url: "Uploader.ashx?username=" + username.toString(),
maxFiles: 5,
addRemoveLinks: true,
success: function (file, response) {
var imgName = response;
file.previewElement.classList.add("dz-success");
console.log("Successfully uploaded :" + imgName);
},
error: function (file, response) {
file.previewElement.classList.add("dz-error");
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<asp:LinkButton ID="lbtUsername" runat="server" Font-Names="Verdana" Text="Dotnetdrizzles@gmail.com" Font-Size="Large" Font-Underline="True" ForeColor="#FF0066"></asp:LinkButton>
<div id="dZUpload" style="width:500px; margin:0 auto;" class="dropzone" >
<div class="dz-default dz-message">
Drag & Drop Images [5] here.
<br />
</div>
</div>
</div>
</form>
</body>
</html>
CREATE TABLE [dbo].[imagereg] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[imgname] VARCHAR (50) NOT NULL,
[imgpath] NVARCHAR (50) NOT NULL,
[username] VARCHAR (50) NOT NULL,
[imgheight] VARCHAR (50) NOT NULL,
[imgwidth] VARCHAR (50) NOT NULL,
[imgsize] VARCHAR (50) NOT NULL,
[date1] VARCHAR (50) NOT NULL,
[month1] VARCHAR (50) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
Uploader.ashx
<%@ WebHandler Language="C#" Class="Uploader" %>
using System;
using System.Web;
using System.IO;
using System.Web.Script.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
public class Uploader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
{
context.Response.ContentType = "text/plain";
string id = context.Request.QueryString["username"].ToString();
string username = id.Substring(0, id.IndexOf("@"));
if (context.Request.QueryString["username"].ToString() != "")
{
string dirFullPath = HttpContext.Current.Server.MapPath("~/IMAGES/");
string[] files;
int numFiles;
string str_image = "";
if ((context.Request.QueryString["username"].ToString() != ""))
{
HttpFileCollection fil = context.Request.Files;
for (int s = 0; s < fil.Count; s++)
{
HttpPostedFile file = context.Request.Files[s];
string fileName = file.FileName;
string fileExtension = file.ContentType;
files = System.IO.Directory.GetFiles(dirFullPath);
numFiles = files.Length;
numFiles = numFiles + 1;
/////// Image Path Get ///////
fileExtension = Path.GetExtension(fileName);
str_image = username + "_" + numFiles.ToString() + fileExtension;
/////// Image Path Get End ///////
string pathToSave = HttpContext.Current.Server.MapPath("~/IMAGES/") + str_image;
file.SaveAs(pathToSave);
// img size ////
System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream);
int height = img.Height;
int width = img.Width;
decimal size = Math.Round(((decimal)file.ContentLength / (decimal)1024), 2);
// image size end //
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
con.Open();
DateTime dt = Convert.ToDateTime(DateTime.Now.ToShortDateString());
string month = dt.Month.ToString() + "/" + dt.Year.ToString();
string date = dt.Day.ToString() + "/" + dt.Month.ToString() + "/" + dt.Year.ToString();
SqlCommand cmd = new SqlCommand("insert into imagereg(imgname,username,imgpath,imgheight,imgwidth,imgsize,date1,month1) values('" + str_image.ToString() + "','" + id.ToString() + "','" + "~/IMAGES/" + str_image.ToString() + "','"+height.ToString()+"','"+width.ToString()+"','"+size.ToString()+"','"+date.ToString()+"','"+month.ToString()+"')", con);
cmd.ExecuteNonQuery();
context.Response.Write(str_image);
}
}
}
}
catch (Exception ex)
{
context.Response.Write("ERROR: "+ex.Message);
}
}
public bool IsReusable {
get {
return false;
}
}
}
I guess I am the only one who came here to share my very own experience. Guess what!? I am using my laptop for almost the past 2 years, but I had no idea of solving some basic issues. I do not know how to Download Cracked Pro Softwares But thankfully, I recently visited a website named vstfull.com
ReplyDeletedropzone Crack
abbyy-fine-reader Crack
easybits-magic-desktop
Wow, amazing block structure! How long
ReplyDeleteHave you written a blog before? Working on a blog seems easy.
The overview of your website is pretty good, not to mention what it does.
In the content!
vstpatch.net
OmniGraffle Crack
Modo Bass Crack
Dropzone Crack
Valhalla Room Crack
Red Sounds Trap Serum Crack
I thought this was a pretty interesting read when it comes to this topic. Thank you
ReplyDeleteNTLite Crack
REAPER Crack
TeamViewer Crack
Dropzone Crack
iExplorer Crack
I am very impressed with your post because this post is very beneficial for me and provides a piece of new knowledge to me.
ReplyDeleteBlueStacks Crack
DFX Audio Enhancer Crack
Volcano Box Crack
Dropzone Crack
Final Cut Pro X Crack
I thought this was a pretty interesting read when it comes to this topic. Thank you
ReplyDeleteNsasoft Office Product Key Finder Crack
MacBooster Crack
Dropzone Crack
Minitab Crack
Would you be interested in exchanging links?
ReplyDeleteI'm really impressed with your writing skills, as smart as the structure of your weblog.
reFX Nexus 3 Crack
Waves Full Bundle VST Crack
Electric Sunburst Kontakt Crack
Wavesfactory Cassette Crack