begin process at 2012 05 27 06:20:32
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Composants

 > CREATION DE FICHIER ZIP EN ASP

CREATION DE FICHIER ZIP EN ASP


 Information sur la source

Note :
5 / 10 - par 1 personne
5,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Composants Niveau :Débutant Date de création :07/06/2002 Date de mise à jour :07/06/2002 17:48:45 Vu :21 589

Auteur : vandrayn

Ecrire un message privé
Site perso
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note

 Description

ce code permet de creer des fichier zip en asp

Source

  • <%@ Language=VBScript %>
  • <%
  • ' This ASP script is a sample provided for the Xceed Zip Compression Library.
  • ' It is called by the frmSelect.htm web page file.
  • ' Download the component in trial version :
  • ' http://www.xceedsoft.com/download/ZipCompL/index.htm
  • ' Download the application :
  • ' http://www.xceedsoft.com/cs/results.asp?id=111
  • Dim xZip ' Will represent an instance of the Xceed Zip object
  • Dim ResultCode ' Result Code from the Zip method
  • Dim sFilesChosen ' HTML output string
  • Dim sRandom ' Random number string
  • Dim sFilename ' Filename of self-extracting zip file to create on server
  • Dim sDownloadURL ' The URL where your browser will download the zip file from
  • Dim Introtext ' The text for the self-extracting zip file's introduction dialog
  • ' Change these constants below for your own sever, and make
  • ' sure the File1.txt, File2.txt and File3.txt files are placed
  • ' in the PATH_FOR_SOURCE_FILES folder. The xcdsfx32.bin
  • ' self-extractor binary file should also be placed in this folder.
  • Const PATH_FOR_SOURCE_FILES = "D:\InetPub\testwebsite\Send\"
  • Const PATH_FOR_ZIP_FILE = "D:\InetPub\testwebsite\Send\Zipfiles\"
  • Const DOWNLOAD_URL = "http://servername/Send/Zipfiles/"
  • ' Instanciate the Xceed Zip object (the xceedzip.dll should be
  • ' installed on the server, of course)
  • Set xZip = Server.CreateObject("XceedSoftware.XceedZip.4")
  • ' If you are using the free trial version of Xceed Zip, you'll
  • ' need to run the Xceed Zip trial version's setup program on
  • ' the server, otherwise it will complain it is not licensed.
  • ' If you are a registered user, uncomment the following line
  • ' and replace the text in quotes with your license key.
  • ' xZip.License("your license key goes here")
  • ' Now, we tell Xceed Zip where to create the self-extracting
  • ' zip file. For this sample, we make the zip file name include the
  • ' client's IP address or name in. That way, if multiple users
  • ' are using this ASP page to create zip files at the same time,
  • ' each user has a unique zip filename to download.
  • sFilename = PATH_FOR_ZIP_FILE & Request.ServerVariables("REMOTE_HOST") & ".exe"
  • xZip.ZipFilename = sFilename
  • ' Now lets set Xceed Zip's options to customize the self-extracting zip file
  • sFilesChosen = ""
  • if uCase(Request("chkFile1")) = "ON" then
  • sFilesChosen = "File1.txt<BR>"
  • xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File1.txt")
  • end if
  • if uCase(Request("chkFile2")) = "ON" then
  • sFilesChosen = sFilesChosen & "File2.txt<BR>"
  • xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File2.txt")
  • end if
  • if uCase(Request("chkFile3")) = "ON" then
  • sFilesChosen = sFilesChosen & "File3.txt<BR>"
  • xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File3.txt")
  • end if
  • xZip.UseTempFile = False ' No need for a temp file for this application
  • xZip.PreservePaths = False ' Do not store the paths where the source files are from
  • xZip.SfxBinaryModule = PATH_FOR_SOURCE_FILES & "xcdsfx32.bin"
  • Introtext = "This self-extracting zip file contains the file(s) you selected "
  • Introtext = Introtext + "to download. The files are password-protected, so you "
  • Introtext = Introtext + "will need to enter a password. Click 'OK' to continue."
  • xZip.SfxMessages(xsmIntro) = Introtext
  • xZip.SfxStrings(xssTitle) = "Custom zip file for " + Trim(Request("txtIntro")) ' Uses name entered on the web page
  • xZip.SfxDefaultUnzipToFolder = Trim(Request("txtUnzipFolder")) ' The unzip folder entered on the web page
  • xZip.EncryptionPassword = Trim(Request("txtPassword")) ' The password entered on the web page
  • ' Now run the command to create the self-extracting zip file
  • ResultCode = xZip.Zip
  • If ResultCode = 0 then
  • sDownloadPath = DOWNLOAD_URL & Request.ServerVariables("REMOTE_HOST") & ".exe"
  • Response.ContentType = "application/x-gzip"
  • Response.Redirect (sDownloadPath)
  • else
  • %>
  • <HTML>
  • <HEAD>
  • <TITLE>
  • Custom zip file creation error.
  • </TITLE>
  • </HEAD>
  • <BODY>
  • <STRONG>
  • You have selected to download the following files:
  • <P>
  • </STRONG>
  • <BR>
  • <%
  • Response.Write(sFilesChosen)
  • %>
  • But the following error from Xceed Zip was returned: <P>
  • <%
  • Response.Write(xZip.GetErrorDescription(xvtError ,ResultCode))
  • %></P>
  • </BODY>
  • </HTML>
  • <%
  • end if
  • set xZip = Nothing
  • %>
  • </BODY>
  • </HTML>
<%@ Language=VBScript %>

<%
	' This ASP script is a sample provided for the Xceed Zip Compression Library.
	' It is called by the frmSelect.htm web page file. 
	' Download the component in trial version : 
	' http://www.xceedsoft.com/download/ZipCompL/index.htm
	' Download the application :
	' http://www.xceedsoft.com/cs/results.asp?id=111

	Dim xZip			' Will represent an instance of the Xceed Zip object
	Dim ResultCode		' Result Code from the Zip method
	Dim sFilesChosen	' HTML output string 
	Dim sRandom			' Random number string
	Dim sFilename		' Filename of self-extracting zip file to create on server
	Dim sDownloadURL	' The URL where your browser will download the zip file from
	Dim Introtext		' The text for the self-extracting zip file's introduction dialog

	' Change these constants below for your own sever, and make
	' sure the File1.txt, File2.txt and File3.txt files are placed
	' in the PATH_FOR_SOURCE_FILES folder. The xcdsfx32.bin
	' self-extractor binary file should also be placed in this folder.

	Const PATH_FOR_SOURCE_FILES = "D:\InetPub\testwebsite\Send\"
	Const PATH_FOR_ZIP_FILE = "D:\InetPub\testwebsite\Send\Zipfiles\"
	Const DOWNLOAD_URL = "http://servername/Send/Zipfiles/"

	' Instanciate the Xceed Zip object (the xceedzip.dll should be
	' installed on the server, of course)

	Set xZip = Server.CreateObject("XceedSoftware.XceedZip.4")
	
	' If you are using the free trial version of Xceed Zip, you'll
	' need to run the Xceed Zip trial version's setup program on
	' the server, otherwise it will complain it is not licensed.
	
	' If you are a registered user, uncomment the following line
	' and replace the text in quotes with your license key.
		
	' xZip.License("your license key goes here")
		
	' Now, we tell Xceed Zip where to create the self-extracting
	' zip file.	For this sample, we make the zip file name include the
	' client's IP address or name in. That way, if multiple users
	' are using this ASP page to create zip files at the same time,
	' each user has a unique zip filename to download. 
		
	sFilename = PATH_FOR_ZIP_FILE & Request.ServerVariables("REMOTE_HOST") & ".exe"
			
	xZip.ZipFilename = sFilename
	
	' Now lets set Xceed Zip's options to customize the self-extracting zip file
		
	sFilesChosen = ""		
		
	if uCase(Request("chkFile1")) = "ON" then
		sFilesChosen = "File1.txt<BR>"
		xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File1.txt")
	end if
		
	if uCase(Request("chkFile2")) = "ON" then
		sFilesChosen = sFilesChosen & "File2.txt<BR>"
		xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File2.txt")
	end if

	if uCase(Request("chkFile3")) = "ON" then
		sFilesChosen = sFilesChosen & "File3.txt<BR>"
		xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File3.txt")
	end if
		
	xZip.UseTempFile = False			' No need for a temp file for this application
	xZip.PreservePaths = False			' Do not store the paths where the source files are from

	xZip.SfxBinaryModule = PATH_FOR_SOURCE_FILES & "xcdsfx32.bin"

	Introtext = "This self-extracting zip file contains the file(s) you selected "
	Introtext = Introtext + "to download. The files are password-protected, so you "
	Introtext = Introtext + "will need to enter a password. Click 'OK' to continue."

	xZip.SfxMessages(xsmIntro) = Introtext

	xZip.SfxStrings(xssTitle) = "Custom zip file for " + Trim(Request("txtIntro")) ' Uses name entered on the web page
	xZip.SfxDefaultUnzipToFolder = Trim(Request("txtUnzipFolder")) ' The unzip folder entered on the web page
	xZip.EncryptionPassword = Trim(Request("txtPassword")) ' The password entered on the web page

	' Now run the command to create the self-extracting zip file
	
	ResultCode = xZip.Zip  
		
	If ResultCode = 0 then
		sDownloadPath =  DOWNLOAD_URL & Request.ServerVariables("REMOTE_HOST") & ".exe"
		Response.ContentType = "application/x-gzip"
		Response.Redirect (sDownloadPath)
	else
	
%>

<HTML>
<HEAD>
<TITLE>
Custom zip file creation error.
</TITLE>
</HEAD>

<BODY>
<STRONG>
You have selected to download the following files:
<P>
</STRONG>
<BR>
<%
		Response.Write(sFilesChosen)
%>
But the following error from Xceed Zip was returned: <P>
<%		
		Response.Write(xZip.GetErrorDescription(xvtError ,ResultCode))
%></P> 

</BODY>
</HTML>
<%
	end if	
	
	set xZip = Nothing
%>

</BODY>

</HTML>  



 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) CUSTOM USER CONTROL COLLECTION par ranouf
Source avec Zip Source .NET (Dotnet) COMPACTER DU JAVASCRIPT par jesusonline
Source avec Zip Source avec une capture Source .NET (Dotnet) WEBCONTROL WYSIWYG POUR ASP.NET par Yxion
Source avec Zip Source avec une capture ANTIBOT par ghuysmans99
INCLURE UNE LIBRAIRIE par Warwick

Commentaires et avis

Commentaire de Imax le 08/06/2002 10:43:49

Dommage qu'il s'agisse d'un composant payant !

Commentaire de Stephman le 26/06/2002 21:11:50

Ce serrait mieux avec un composant gratuits, mais bon, cela faisait longtemps que j'en cherchais un(et je ne pense pas qu'il en existe).

Commentaire de zeb13 le 13/12/2003 19:10:00

pour info et c'est gratos :
http://www.xstandard.com/page.asp?p=C9891D8A-5390-44ED-BC60-2267ED6763A7&s=D18615A1-458B-4074-BBD5-81AB02E2E042

Commentaire de olivierdel le 14/12/2003 16:15:21

merci pour ce petit lien mais le descriptif de son utilisation est un peut succin à tu un code pour l'utiliser?
merci beaucoup! :-)

Commentaire de zeb13 le 15/12/2003 10:09:27

http://www.xstandard.com/page.asp?p=128ACD87-88F8-420D-8BF1-DD8F5976C99A tu y trouveras trois exemples.

Commentaire de Jackboy le 13/07/2004 14:29:50

Les exemples sont ici http://www.xstandard.com/page.asp?p=A4372B00-8D7F-4166-977C-64E5C4E3708E&ss=7559F3C1-DAD9-48FE-A76D-D7ECB23F0DD0

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,390 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales