mcrmg
asked on
Dropzone upload Max file size
Hi,
I use Dropzone to upload the files to the site.
http://www.dropzonejs.com/#events
Everything works fine, but is there a way to set the max file size and file type? thanks
I use Dropzone to upload the files to the site.
http://www.dropzonejs.com/#events
<form id="upload" method="post" action="Docs.aspx" enctype="multipart/form-data">
<div id="drop">
Drag & Drop Here
<a>Browse</a>
<input type="file" name="upl" multiple />
</div>
<ul>
<!-- The file uploads will be shown here -->
</ul>
</form>
this is the code behind protected void Page_Load(object sender, EventArgs e)
{
bool exists = System.IO.Directory.Exists(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));
if (!exists)
System.IO.Directory.CreateDirectory(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));
DirectoryInfo flDis = new DirectoryInfo(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));
foreach (string s in Request.Files)
{
HttpPostedFile file = Request.Files[s];
int fileSizeInBytes = file.ContentLength;
string fileName = file.FileName;
string fileExtension = "";
if (!string.IsNullOrEmpty(fileName))
fileExtension = Path.GetExtension(fileName);
string savedFileName = Guid.NewGuid().ToString() + fileExtension;
//string savedFileName = fileName;
string filename = Server.MapPath("~/DocStorage/File-" + Session["sCMID"] + "/" ) + savedFileName;
file.SaveAs(filename);
}
FileInfo[] filesInDir = flDis.GetFiles("*.*");
List<ListItem> files = new List<ListItem>();
foreach (FileInfo foundFile in filesInDir)
{
files.Add(new ListItem(Path.GetFileName(foundFile.FullName), foundFile.FullName));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
Everything works fine, but is there a way to set the max file size and file type? thanks
ASKER
That is what puzzles me. Where do I put it? thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much
we have the parameter maxFilesize
Dropzone.options.upload = {
maxFilesize: 2, // 2 MB