views:

42

answers:

3

I would like to be able to unpack a .zip file using ASP classic.

I have had a bit of a poke around on google for something that will allow me to do this, and there seems to be a fair amount libraries out there. However all of these as far as I can tell require me to install a third party DLL.

The server that this script will be deployed on (or more accurately the IT department that control said server) will not allow me to use these to extend ASP's functionality and do what I have been asked to do (totally paradoxical!).

Is there any class library's out there that I might just be able to throw in as an include?

thanks for your time

A: 

You may find this useful:

Sarfraz
thanks but all those options require me to install something on the server, and as I previously suggested this is not possible.
Phood
A: 

Not sure is you can make it work with ASP, but in this project you will find a way to unZip in VB using a DLL, but you don't need to register the DLL, just put it somewhere where the class can find it.

I've used it in a VB 6 compiled app, but maybe you can adapt it to ASP. Not sure.

This is the code you will need: UnZip.cls
Hope it helps.

Eduardo Molteni
this looks promising! I'll give it a go
Phood
A: 

I have solved my problem... it's pretty messy, far from ideal, and dependant on server set up, but for the sake of anyone that has a similar problem and server in future here is how I solved it.

Basically I used PHP's ZIP library which seems to be installed on the server that I'm working on and made an unzip.php file:

<?PHP

$infile = $_REQUEST['infile'];
$outfile = $_REQUEST['outfile'];

$input_folder = "uploads";
$output_folder = "templates";

echo "false";

$zip = zip_open($input_folder."/".$infile);
if ($zip) {
  while ($zip_entry = zip_read($zip)) {
    $fp = fopen($output_folder."/".$outfile."/".zip_entry_name($zip_entry), "w");
    if (zip_entry_open($zip, $zip_entry, "r")) {
      $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
      fwrite($fp,"$buf");
      zip_entry_close($zip_entry);
      fclose($fp);
    } else {
    echo "false";
    exit;
    }
  }
    echo "true";
  zip_close($zip);
} else {
    echo "false";
    exit;
}

?>

Then where I wanted to call this in my ASP script I HTTPXML'd to the PHP file location on same server with my variables as part of the querystring.

Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://" & strdomain & "/unzip.php?infile="& filename &"&outfile=" & out_foldername, False
xml.Send
if xml.responseText = "true" then
    SaveFiles = SaveFiles & "(unzip successful!)"
else
    SaveFiles = SaveFiles & "(unzip failed!)"
end if
Set xml = Nothing
next

where

filename     =   The name of the file that you want to unzip
out_folder   =   The name of the folder that you want put your unzipped files into
strdomain    =   Request.ServerVariables("HTTP_HOST")
SaveFiles    =   my return variable.

I'm sure there must be a better way of doing this, but for the time being in my situation this seems to work ok (and hopefully no one will ever know!).

Phood