ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.How to upload multiple photos using fileupload control in ASP.NetHi @cywa,<br />Please try the following<br /><br /><a href = 'link(Threads/144024/How-to-Upload-multiple-files-using-single-FileUpload-control-in-ASPNet-45/)'>How to Upload multiple files using single FileUpload control in ASP.Net 4.5</a><br /><br />It might help you.<br /><br />Cheers Andrea.http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 20 Dec 2016 07:07:37 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi <a class="username" rel="cywa"> cywa</a>,</p> <p>Refer the below article.</p> <h1 class="header"><a title="Uploading Multiple Files using FileUpload Control in ASP.Net 2.0, 3.0 and 3.5'a" href="http://www.aspsnippets.com/Articles/Uploading-Multiple-Files-using-FileUpload-Control-in-ASPNet-20-30-and-35.aspx">Uploading Multiple Files using FileUpload Control in ASP.Net 2.0, 3.0 and 3.5</a></h1>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 20 Dec 2016 07:08:33 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi,&nbsp; dharmendr and andrea thank you for replying. &nbsp;i need to develope based on this code. while clicking on btnupload i need to upload in sql database</p> <pre class="brush: csharp"> &lt;asp:FileUpload ID=&#34;FileUpload1&#34; CssClass=&#34;FileUpload2&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:FileUpload ID=&#34;FileUpload2&#34; runat=&#34;server&#34; CssClass=&#34;FileUpload2&#34; /&gt; &lt;br /&gt; &lt;asp:FileUpload ID=&#34;FileUpload3&#34; CssClass=&#34;FileUpload2&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Button ID=&#34;btnUpload&#34; runat=&#34;server&#34; CssClass=&#34;button&#34; Text=&#34;upload&#34; Style=&#34;width: 30%;&#34; /&gt;</pre> <p>thanks&nbsp; cywa</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 20 Dec 2016 08:28:24 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi <a class="username" rel="cywa"> cywa</a>,</p> <p>How you want to save the uploaded files in sql server database as in single column value separated by comma or in different rows?</p> <p>if possible share your table data where you are trying to save the uploaded files.</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 20 Dec 2016 08:35:28 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi AnandM,</p> <p>i want to save these every photos in different rows &nbsp;only, not in a single row .<br /><br /><a href="http://www.aspsnippets.com/Articles/Uploading-Multiple-Files-using-FileUpload-Control-in-ASPNet-20-30-and-35.aspx">http://www.aspsnippets.com/Articles/Uploading-Multiple-Files-using-FileUpload-Control-in-ASPNet-20-30-and-35.aspx</a><br /><br />check this link i want output like this but not in this way..<br /><br />thanks and regards<br />cywa</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 20 Dec 2016 15:15:47 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi <a class="username" rel="cywa"> cywa</a>,</p> <p>I have created a sample which full fill your requirement</p> <p>By taking reference of below article</p> <h1 class="header"><a title="Save and Retrieve images from database in ASP.Net'a" href="http://www.aspsnippets.com/Articles/Save-and-Retrieve-images-from-database-in-ASPNet.aspx">Save and Retrieve images from database in ASP.Net</a></h1> <p>You need to modify the code according to your requirement</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div&gt; &lt;table border=&#34;0&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34;&gt; &lt;tr&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;asp:FileUpload ID=&#34;FileUpload2&#34; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:FileUpload ID=&#34;FileUpload3&#34; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Button ID=&#34;btnUpload&#34; runat=&#34;server&#34; Text=&#34;upload&#34; Style=&#34;width: 30%;&#34; OnClick=&#34;btnUpload_Click&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;asp:Label ID=&#34;lblMessage&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void btnUpload_Click(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; string folderPath = Server.MapPath("~/Images/"); &nbsp;&nbsp;&nbsp; if (FileUpload1.HasFile &amp;&amp; FileUpload2.HasFile &amp;&amp; FileUpload3.HasFile) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string fileUpload1 = Path.GetFileName(FileUpload1.FileName); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InsertImages(fileUpload1, FileUpload1.PostedFile.ContentType, folderPath + fileUpload1); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string fileUpload2 = Path.GetFileName(FileUpload2.FileName); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileUpload2.SaveAs(folderPath + Path.GetFileName(FileUpload2.FileName)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InsertImages(fileUpload2, FileUpload2.PostedFile.ContentType, folderPath + fileUpload2); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string fileUpload3 = Path.GetFileName(FileUpload3.FileName); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileUpload3.SaveAs(folderPath + Path.GetFileName(FileUpload3.FileName)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InsertImages(fileUpload3, FileUpload3.PostedFile.ContentType, folderPath + fileUpload3); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lblMessage.ForeColor = Color.Green; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lblMessage.Text = "All Files Uploaded and Saved Successfully in DataBase."; &nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lblMessage.ForeColor = Color.Red; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lblMessage.Text = "Please Upload All Files"; &nbsp;&nbsp;&nbsp; } } public void InsertImages(string fileName, string contentType, string filePath) { &nbsp;&nbsp;&nbsp; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; &nbsp;&nbsp;&nbsp; using (SqlConnection con = new SqlConnection(constr)) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string query = "INSERT INTO tblFiles VALUES(@Name,@ContentType,@Data,@FilePath)"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (SqlCommand cmd = new SqlCommand(query)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BinaryReader br = new BinaryReader(fs); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Byte[] bytes = br.ReadBytes((Int32)fs.Length); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; br.Close(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fs.Close(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Connection = con; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.AddWithValue("@Name", fileName); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.AddWithValue("@FilePath", filePath); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.AddWithValue("@Data", bytes); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.AddWithValue("@ContentType", contentType); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con.Open(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.ExecuteNonQuery(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con.Close(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; } }</pre> <p><span style="text-decoration: underline;">ScreenShot</span></p> <p><img src="http://i988.photobucket.com/albums/af3/mudassarkhan/176212_1.gif" alt="" width="610" height="444" /></p> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Wed, 21 Dec 2016 02:48:03 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi AnandM,<br /><br />Thank you for your reply and code of this method .<br /><br />i need to save photo as binary data only in sql database, not in a filepath and save in a temperory folder.<br /><br />sorry for late reply.<br /><br />Thanks and regards<br /><br />cywa</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Thu, 22 Dec 2016 01:59:42 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi <a class="username" rel="cywa"> cywa</a>,</p> <p>I have modified my code please refer below link</p> <p><a href="http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-with-two-many-fileupload-control-in-a-single-button-click-in-sqlserver/Replies/6#Replies">http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-with-two-many-fileupload-control-in-a-single-button-click-in-sqlserver/Replies/6#Replies</a></p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Thu, 22 Dec 2016 04:15:18 GMTHow to upload multiple photos using fileupload control in ASP.Net<p>Hi AnandhM,<br /><br />Thank you verymuch for the solution,&nbsp;i tried this way with little adjustments.<br /><br />Thanks and regards,</p> <p>cywa</p>http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/http://www.aspforums.net/Threads/176212/How-to-upload-multiple-photos-using-fileupload-control-in-ASPNet/Tue, 27 Dec 2016 05:12:17 GMT