Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Re:Re: Force Downloads


Message #1 by "Ray Bowles" <ray@p...> on Mon, 15 Oct 2001 17:29:55
I was wondering if you ever did the opposite of this. I've be scripting 

and rescripting for almost a week now and even my "simple" stripped down 

version won't work. I am trying to have a zip file, that a user uploads, 

unzip into a dynamic folder structure for online docs. Here is the test 

(simple) code I am using followed by the error I get. I've played with 

user rights including assigning admin to IUSR. Oh, I've tried winzip and 

pkzip.

---------------------------------

<%@ LANGUAGE="VBScript" %>

<%

Set Executor = Server.CreateObject("ASPExec.Execute")

    

if (err.number <> 0) then

	response.write "Error: " & err.description

else

	Executor.Application = "cmd /c C:\Progra~1

\pkware\pkzipc\pkzipc.exe -extract C:\inetpub4\wwwroot\test.zip 

C:\inetpub4\wwwroot\test"

	Executor.Parameters = ""

	strResult = Executor.ExecuteDosApp

	Set objExecutor = Nothing

	Response.Write "<pre>" & strResult & "</pre>"

end if

%>

---------------------------------



*********************************

PKZIP(R)  Version 4.00  FAST! Compression Utility for Windows 

Copyright 1989-2000 PKWARE Inc.  All Rights Reserved. Shareware Version 

PKZIP Reg. U.S. Pat. and Tm. Off.  Patent No. 5,051,745







PKZIP: (E16) Can't open for write access, file: C:\inetpub4

\wwwroot\test.zip



**********************************

> I developed a web application half a year ago that

> does exactly this.  It took awhile to work out, and it

> was questions for this that in fact brought me to

> these wonderful WROX mailing lists for answers.

> 

> My application is for Real Estate.  It reads a couple

> huge (18,000+ lines) text files, where each line has

> information that must be copied into four different

> places for four different users.  Each line is

> appended to a text file in these directories.  Each

> line also has a key that is used to identify a graphic

> in a huge directory, and the location of this graphic

> is appended to another text file in these four

> directories.  The end user logs into the site, and is

> presented with a "download now" button.  This button

> submits to an ASP script that does the following:

> 

> 1) Creates a ZIP archive, puts the line-appended text

> file in it.

> 2) Reads the graphic file, grabs the graphic from

> specified location and adds it to the archive.

> 4) Sends the archive to the user by instantiating a

> download dialogue (you know, "save as... or open

> target").

> 

> Now... the scripts. Let's hope I can find everything

> needed and detail the relevant parts for you...

> 

> first, the components.  I use ASPExec to run the

> applications needed.  This is available for free from

> www.serverobjects.com.  The applications needed are

> WinZip, which pretty much everyone has, and if you

> want it to be a self-extracting executable then you

> need WinZipSE, which has a small license cost.  You

> probably don't want/need the SE, I just had it because

> we weren't positive that all clients would have WinZip

> to unzip the archives.

> 

> Once you've got ASPExec installed (quite easy), and

> WinZip, you're set to script.  Looking into WinZip's

> documentation, I discovered that you can only send a

> limited amount of characters as parameters to pass

> (meaning there's a limit on the number of files you

> can include by calling it through commandline).  But,

> luckily, you can put all the parameters you want into

> a file and just indicate the file in the commandline.

> 

> So, the basic lines for zipping are thus:

> 

> <%

> Set Executor = Server.CreateObject("ASPExec.Execute")

> 

> Executor.Application = "E:\WinZip\WZZIP.exe"

> Executor.Parameters = Params

> Executor.TimeOut = 10000  ' long time, cuze lots of

> files

> intResult = Executor.ExecuteWinAppAndWait

> %>

> 

> The Params variable is a string indicating the

> location and filename to save the archive, and the

> files to include, which I constructed with conditional

> statements.  Here's a sample of what it should look

> like:

> 

> <%

> Params = "F:\Inetpub\wwwroot\listings\" & userid &

> "\listings.zip " ' location to save archive

> fileParams = " @" & graphicFile ' text file detailing

> all graphics to be included in archive

> Params = Params & fileParams & "Listings.txt" ' the

> file containing their listings

> %>

> 

> So it's like the parameter line is this:

> [archive name] [@TextFile] [file to include] 

> 

> and the actual line that executed, as though you typed

> it in the "Run" box in windows:

> 

> E:\WinZip\WZZIP.exe

> F:\Inetpub\wwwroot\listings\1234567\listings.zip

> @photos_to_send.txt Listings.txt

> 

> and this will zip Listings.txt and all files specified

> in "photos_to_send.txt" into an archive called

> "listings.zip" located at

> "F:\Inetpub\wwwroot\listings\1234567\".

> 

> Now, the next part is to send that to the user once

> it's ready.  Simple simple thing..

> 

> <%

> Response.ContentType = "application/unknown"

> Response.Redirect (iZipFile)

> %>

> 

> and that's the end of the script.

> Here, let me put it together for you.  Following is an

> exact sample of the script you want.

> 

> <%

> ' set parameter variables

> Params = "F:\Inetpub\wwwroot\listings\" & userid &

> "\listings.zip " ' location to save archive

> fileParams = " @" & graphicFile ' text file detailing

> all graphics to be included in archive

> Params = Params & fileParams & " Listings.txt" ' the

> file containing their listings

> 

> Set Executor = Server.CreateObject("ASPExec.Execute")

> 

> 'Zip this baby

> Executor.Application = "E:\WinZip\WZZIP.exe"

> Executor.Parameters = Params

> Executor.TimeOut = 10000  ' long time, cuze lots of

> files

> intResult = Executor.ExecuteWinAppAndWait

> 

> 'send it

> Response.ContentType = "application/unknown"

> Response.Redirect (iZipFile)

> %>

> 

> Well, that was fun.  Hope that helps you.  Feel free

> to ask any questions, but please make sure you try

> testing everything you can think of before coming

> back... I know there will probably be simple errors

> initially... for example, make sure the web account

> (IUSER) has write permissions on the directory you're

> writing the archive to.

> 

> Regards,

> Michael Filip

> 

> -----Original Message-----

> From: Shaun Steckley [mailto:SSTECKLEY@P...]

> Sent: Thursday, May 03, 2001 3:19 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Re:Re: Force Downloads

> 

> 

> Do you have a sample script to share that does this?

> 

> -----Original Message-----

> From: TomMallard [mailto:mallard@s...]

> Sent: Thursday, May 03, 2001 10:01 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Re:Re: Force Downloads

> 

> 

> Zipping on the fly has advantages, and, people nearly

> always reject the idea

> at first because they think it's too much extra work.

> All I can say is pkzip

> is easy to use to zip on the fly with a command line

> called with dynamic

> arguments by windows host from an asp page.

> 

> Zipping most of the library of 24k files may also be

> an option. If you flip

> through the folders and use lastmodified, I'll bet

> most of these files

> haven't been touched in a long time so can be zipped

> in advance, leaving the

> active files to be zipped on the fly and easier to

> change for content

> providers.

> 

> $.02

> 

> tom


  Return to Index