Note that there are some explanatory texts on larger screens.

plurals
  1. POProgress bar for uploading images mvc
    primarykey
    data
    text
    <p>I have an MVC asp.net application to upload multiple images in a folder in my app. It just uploads the images, compresses and saves it to a folder and saves its thumbnail to another folder. The upload is happening in background as i can carry out doing other jobs in my app. </p> <p>It takes some time to upload large no.of images. So I need to show the status of uploading images in a floating dialog box or pop-up window as progress bar and when upload is finished i should get an alert telling process has been finished. </p> <h2>In View</h2> <pre><code>&lt;form action="" method="post" enctype="multipart/form-data"&gt; @Html.Label("Select the property : "); @Html.DropDownList("Address", new SelectList(ViewBag.Address as System.Collections.IEnumerable), "---Select---",new { id = "add"}) &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="files" id="file" multiple="true"/&gt; &lt;input type="submit" /&gt; </code></pre> <h2> </h2> <h2>In Controller</h2> <pre><code> [HttpPost] public ActionResult Index(HttpPostedFileBase[] files, FormCollection c) { int no = 0; string path = Path.Combine(Server.MapPath("~/Images"), c["Address"].Replace(' ', '_')); string fn = ""; if (!Directory.Exists(path)) Directory.CreateDirectory(path); else no = Directory.GetFiles(path).Length; foreach (var file in files) { string fname = "img_" + no++ + file.FileName.Substring(file.FileName.LastIndexOf('.')); fn = Path.Combine(path, fname); Thread.Sleep(10000); ImageCodecInfo jpgEncoder = null; ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); foreach (ImageCodecInfo codec in codecs) { if (codec.FormatID == ImageFormat.Jpeg.Guid) { jpgEncoder = codec; break; } } var image1 = System.Drawing.Image.FromStream(file.InputStream, true, true); if (jpgEncoder != null) { Encoder encoder = Encoder.Quality; EncoderParameters encoderParameters = new EncoderParameters(1); long quality = 20; EncoderParameter encoderParameter = new EncoderParameter(encoder, quality); encoderParameters.Param[0] = encoderParameter; FileStream ms = new FileStream(fn, FileMode.Create, FileAccess.Write); image1.Save(ms, jpgEncoder, encoderParameters); ms.Flush(); ms.Close(); } using (var image = System.Drawing.Image.FromStream(file.InputStream, true, true)) /* Creates Image from specified data stream */ { using (var thumb = image.GetThumbnailImage( 50, /* width*/ 60, /* height*/ () =&gt; false, IntPtr.Zero)) { var jpgInfo = ImageCodecInfo.GetImageEncoders().Where(codecInfo =&gt; codecInfo.MimeType == "image/png").First(); /* Returns array of image encoder objects built into GDI+ */ using (var encParams = new EncoderParameters(1)) { string pa = Path.Combine(path, "Thumb"); if (!Directory.Exists(pa)) { Directory.CreateDirectory(pa); } string outputPath = Path.Combine(pa, fname); long quality = 100; encParams.Param[0] = new EncoderParameter(Encoder.Quality, quality); thumb.Save(outputPath, jpgInfo, encParams); } } } } return RedirectToAction("Index"); </code></pre> <h2> }</h2> <p>Can any one please help me to make progress bar in a floating dialog box or pop-up window in my app??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload