ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Upload and save file in Folder (Dictionary) using jQuery Uploadify Plugin in ASP.Net<p>Hi <a class="username" rel="simflex"> simflex</a>,</p> <p>Refer below link -</p> <h1 class="header"><a class="title f16" href="https://www.aspforums.net:443/Threads/299826/Uploadify-jquery-Plugin-works-on-local-but-on-Server-it-throws-IO-Error/">Uploadify jquery Plugin works on local but on Server it throws IO Error</a></h1>https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/Fri, 10 May 2019 02:05:26 GMTUpload and save file in Folder (Dictionary) using jQuery Uploadify Plugin in ASP.Net<p>Thank you very much Pandeyism,</p> <p>Hope I am not being too much of a burden but what about the other two issues?</p> <p>1, The attachment is working but the images are not getting stored in the Uploads folder.</p> <p>I suspect that when you click to attach files, when the attached file is displayed on the screen, it means that it has been stored to the Uploads folder, no?</p> <p>2, And when you click the [x] to remove a file, it doesn't remove the file.</p> <p>Is it because the file is not stored to the Uploads folder?</p> <p>Many thanks for your patience and assistance.</p>https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/Fri, 10 May 2019 07:40:46 GMTUpload and save file in Folder (Dictionary) using jQuery Uploadify Plugin in ASP.Net<p>Hi <a class="username" rel="simflex"> simflex</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;scripts/jquery-1.3.2.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;scripts/jquery.uploadify.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#34;[id*=FileUpload1]&#34;).fileUpload({ &#39;uploader&#39;: &#39;scripts/uploader.swf&#39;, &#39;cancelImg&#39;: &#39;images/cancel.png&#39;, &#39;buttonText&#39;: &#39;Attach Files&#39;, &#39;script&#39;: &#39;UploadCS.ashx&#39;, &#39;folder&#39;: &#39;uploads&#39;, &#39;multi&#39;: true, &#39;auto&#39;: true, &#39;scriptData&#39;: { key: &#39;&lt;%=Key %&gt;&#39; }, &#39;onSelect&#39;: function (event, ID, file) { $(&#34;#attachedfiles tr&#34;).each(function () { if ($(&#34;td&#34;, this).eq(0).html() == file.name) { alert(file.name + &#34; already uploaded.&#34;); $(&#34;[id*=FileUpload1]&#34;).fileUploadCancel(ID); return; } }); }, &#39;onComplete&#39;: function (event, ID, file, response, data) { $(&#34;#attachedfiles&#34;).append(&#34;&lt;tr&gt;&lt;td&gt;&#34; + file.name + &#34;&lt;/td&gt;&lt;td&gt;&lt;a href = &#39;javascript:;&#39;&gt;[x]&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&#34;); } }); }); $(&#34;#attachedfiles a&#34;).live(&#34;click&#34;, function () { var row = $(this).closest(&#34;tr&#34;); var fileName = $(&#34;td&#34;, row).eq(0).html(); $.ajax({ type: &#34;POST&#34;, url: &#34;CS.aspx/RemoveFile&#34;, data: &#39;{fileName: &#34;&#39; + fileName + &#39;&#34;, key: &#34;&lt;%=Key %&gt;&#34; }&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function () { }, failure: function (response) { alert(response.d); } }); row.remove(); }); &lt;/script&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; To: &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtTo&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Subject: &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtSubject&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Body: &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtBody&#34; runat=&#34;server&#34; TextMode=&#34;MultiLine&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:FileUpload ID=&#34;FileUpload1&#34; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;table id=&#34;attachedfiles&#34;&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Button ID=&#34;btnSend&#34; runat=&#34;server&#34; Text=&#34;Send&#34; OnClick=&#34;btnSend_Click&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Web.Services; using System.Net.Mail; using System.IO;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>UploadCS.ashx</strong></p> <pre class="brush: csharp">&lt;%@ WebHandler Language=&#34;C#&#34; Class=&#34;UploadCS&#34; %&gt; using System; using System.Web; using System.IO; using System.Collections.Generic; public class UploadCS : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = &#34;text/plain&#34;; context.Response.Expires = -1; try { List&lt;HttpPostedFile&gt; files = (List&lt;HttpPostedFile&gt;)context.Cache[context.Request.QueryString[&#34;key&#34;]]; HttpPostedFile postedFile = context.Request.Files[&#34;Filedata&#34;]; files.Add(postedFile); string filename = postedFile.FileName; postedFile.SaveAs(HttpContext.Current.Server.MapPath(&#34;~/Uploads/&#34;) + filename); context.Response.Write(filename); context.Response.StatusCode = 200; } catch (Exception ex) { context.Response.Write(&#34;Error: &#34; + ex.Message); } } public bool IsReusable { get { return false; } } }</pre> <p><strong>CS.aspx.cs</strong></p> <pre class="brush: csharp">protected string Key { get { return ViewState[&#34;Key&#34;].ToString(); } set { ViewState[&#34;Key&#34;] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.Key = Guid.NewGuid().ToString(); Cache[this.Key] = new List&lt;HttpPostedFile&gt;(); } } [WebMethod] public static void RemoveFile(string fileName, string key) { List&lt;HttpPostedFile&gt; files = (List&lt;HttpPostedFile&gt;)HttpContext.Current.Cache[key]; File.Delete(HttpContext.Current.Server.MapPath(&#34;~/Uploads/&#34;) + fileName.ToLower()); }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/https://www.aspforums.net:443/Threads/132542/Upload-and-save-file-in-Folder-Dictionary-using-jQuery-Uploadify-Plugin-in-ASPNet/Fri, 10 May 2019 08:18:26 GMT