how to insert zip folder images in database

Posted by Chanti444 under ASP.NET on 10/4/2011 | Points: 10 | Views : 1974 | Status : [Member] | Replies : 1
hi i hv taken one fileupload control and button. fileupload hs taken zip folder contain images .finallly when i click subitbutton the zip folder is extracted and that images are inserted into database pls help me
send that code pls pls



Posted by: Ndebata on: 10/4/2011 [Member] Starter | Points: 25

In ASPX file
        <asp:FileUpload ID="FileUpload1" runat="server" />

<asp:Button ID="Button1" runat="server"
Text="Button" onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

I am using library
In code behind
private string TempUPath

get { if (!Directory.Exists(Server.MapPath("TempUploadPath"))) Directory.CreateDirectory(Server.MapPath("TempUploadPath")); return Server.MapPath("TempUploadPath"); }
protected void Button1_Click(object sender, EventArgs e)
if (FileUpload1.HasFile && FileUpload1.FileName.ToLower().EndsWith(".zip"))
using (ZipFile zf = ZipFile.Read(FileUpload1.FileContent))
foreach (var item in Directory.GetFiles(TempUPath))
using (StreamReader sr=new StreamReader(item))
byte[] buffer=new byte[sr.BaseStream.Length];
sr.BaseStream.Read(buffer, 0, buffer.Length);
//Save this binary into database....

Label1.Text = "Please select a zip file to upload";

Chanti444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response