hey all,
i am developing a user control which will show a hidden div for uploading files. the idea is to upload multiple file at once. does anyone knows how to do that ?
thanks...
NOTE: the control will be built using ASP.NET and C#.
hey all,
i am developing a user control which will show a hidden div for uploading files. the idea is to upload multiple file at once. does anyone knows how to do that ?
thanks...
NOTE: the control will be built using ASP.NET and C#.
A few practical approaches and pitfalls for a hidden-div multiple-upload control in ASP.NET/C#.
A simple, modern option is an HTML5 file input that supports multiple selection on capable browsers:
<input type="file" name="files" id="files" multiple /> If you must support older browsers, dynamically add more <input type="file"> elements with JavaScript, or use an upload widget/library that provides fallbacks.
Server-side handling (WebForms example): loop Request.Files, validate each file, sanitize the name, and save with a unique filename to avoid collisions:
for (int i = 0; i < Request.Files.Count; i++)
{
var posted = Request.Files[i];
if (posted != null && posted.ContentLength > 0)
{
var fileName = Path.GetFileName(posted.FileName);
// validate extension and size here
var savePath = Path.Combine(Server.MapPath("~/Uploads"),
Guid.NewGuid().ToString() + "_" + fileName);
posted.SaveAs(savePath);
}
} Notes and troubleshooting (based on the thread):
enctype="multipart/form-data". Configure limits in web.config (<httpRuntime maxRequestLength="...">) and IIS (maxAllowedContentLength) for large uploads. If you want progress UI or chunked/large-file support, use XHR2/FormData with server-side chunk assembly or a proven client library that handles browser fallbacks and retries.
Jump to Post— ses5909 60
this code works only for single more than one client use the upload ,then there is bug in application due to SHARED array list.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.