Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow Do I Upload A File & Unzip?How Do I Upload A File & Unzip?
Previous
 
Next
New Post
10/7/2011 3:57 PM
 
I need to be able to give the user an option to upload a zipfile, which my Module would store in a temporary location, unzip it, work with the files and when done, delete all the files and the original zip.

Are there any samples out there to reference?  I looked all over, can't find any.

-Ben

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
10/12/2011 3:30 AM
 
I sense a disturbance in the logic here.

To let the user upload a file (zipped or de not) you go the usual way of uploading a file and saving it.
The zip file (now on the server) can be unzipped .. once again with some known techniques.

Now let's say you let the user "open" that document (ie a link) this document get opened on the user's machine (client side)
There's no way (AFIK) that the server can know the document on the client have been saved and it must update / overwrite the document on the server.

Unless I understood you wrong of course.
 
New Post
10/13/2011 2:40 PM
 
Sorry, I think you misunderstood my request.  I am relatively new to working with DNN Module creation.  I come from a VB.Net programming background, and and refreshing my ASP.Net knowledge.  What I asked for was sample code or directions on how to upload a file to the server, unzip the file on the server, use the files on the server, then delete the files off the server. Unfortunatly telling me to "go the usual way of uploading a file and saving it" leaves me with the same question...How? The "some known techniques" you mentioned is what I am looking for.

After deconstructing some of the source code to the original DNN site, I was able to find some semblance of code that guided me in the process... However, the INPUT object which browses for the file doesn't seem to POST the file up. I am thinking it's because of the location I have placed the code, but I do not know how to fix it.

I have an ASP WIZARD defined on my SETTINGS ControlPage. The default first step appears fine to the user, and when I click on NEXT it kicks off the "NextButtonClick" event without a problem.  However in this event "NextButtonClick", I need to retrieve the file that was uploaded...but this event doesn't seem to cause a POSTBACK.  How do I get the NEXT button of the ASP WIZARD to POSTBACK the file for upload? When I check the Me.cmdBrowse.PostedFile property, I get back NOTHING.

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
10/13/2011 4:58 PM
 
Yes this can be done, DNN ships with the SharpZipLib assembly.

Here is an example.


Using oFileStream As FileStream = File.OpenRead(m_oInfoImport.Path & "\Data\" & m_sFile)
Dim oZipInputStream As ICSharpCode.SharpZipLib.Zip.ZipInputStream = New ICSharpCode.SharpZipLib.Zip.ZipInputStream(oFileStream)
Dim oZipEntry As ICSharpCode.SharpZipLib.Zip.ZipEntry
oZipEntry = oZipInputStream.GetNextEntry()
While Not (oZipEntry Is Nothing)
Dim fileName As String = Path.GetFileName(oZipEntry.Name)
If Not (fileName = String.Empty) Then
Dim streamWriter As FileStream = File.Create(m_oInfoImport.Path & "\Data\" & oZipEntry.Name)
Dim size As Integer = 2048
Dim data() As Byte = New Byte(2048) {}
While (True)
size = oZipInputStream.Read(data, 0, data.Length)
If size > 0 Then
streamWriter.Write(data, 0, size)
Else
Exit While
End If
End While
streamWriter.Close()
End If
' get the next file in the zip
oZipEntry = oZipInputStream.GetNextEntry()
End While
oZipInputStream.Close()
End Using


Robert Harriman
WEBMAZING.NET
AutoWebSuite / BrokerWebSuite

DNN Modules for Auto Dealers and Real Estate Professionals.

 
New Post
10/14/2011 9:29 PM
 
Thank you Robert. You pointed me in the right direction and I was able to figure it out!

Much appreciated!

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow Do I Upload A File & Unzip?How Do I Upload A File & Unzip?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Copyright 2014 by DNN Corp | Terms of Use | Privacy | Design by Parker Moore Design