Solved

Zip files & PHP

Posted on 2004-04-21
15
257 Views
Last Modified: 2008-03-04
How can I zip and unzip files using php ... Can any one give me a simple code plz
                    Thank you in advance,
0
Comment
Question by:COMPUTER_SC_STUDENT
  • 3
  • 3
  • 3
  • +2
15 Comments
 

Expert Comment

by:mobana
ID: 10875805
how if you copy your text and paste it into new text file, e.g: world.txt
<?
$filename = "world.txt";
$fp = fopen($filename, "r");
$buf = fread($fp, filesize($filename));
echo $buf;
?>
hope can help.
0
 
LVL 6

Expert Comment

by:CosminB
ID: 10875813
one solution would be to use COM (if your server is windows)
another would be to use the OLE class form pear(go to http://pear.php.net/ and search for OLE)
0
 
LVL 6

Expert Comment

by:CosminB
ID: 10875835
... sorry I've posted to the wrong question
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:mobana
ID: 10875860
uhm....sorry for wrong post too. it happened same with me...sound the id numbering make the wrong post when there is new thread come in??
0
 

Author Comment

by:COMPUTER_SC_STUDENT
ID: 10875895
I need a complete code plz for openning a Microsoft Word document which already exist ....
I am new in php    plz give me a direct answer plz ....
0
 
LVL 6

Expert Comment

by:CosminB
ID: 10875901
for 20 points ?!? :)
0
 
LVL 14

Expert Comment

by:ThG
ID: 10877170
Please don't create more confusion than needed. This thread is about zip files, this one http:Q_20961487.html is about word files (not "world" *laughing*).
unzipping files in PHP:
system("unzip -a -q yourfile.zip");
0
 

Author Comment

by:COMPUTER_SC_STUDENT
ID: 10877318
<?php
system("unzip -a -q word.zip");
?>

I tried this code but my file "word.zip" still zipped ...
Are you sure that is the code  :)
0
 
LVL 17

Accepted Solution

by:
dorward earned 25 total points
ID: 10878058
0
 
LVL 14

Assisted Solution

by:ThG
ThG earned 25 total points
ID: 10880495
> I tried this code but my file "word.zip" still zipped ...

1. Are you sure you have the "unzip" command? Try specifying the full location to it
2. Are you sure word.zip is in the same directory as the running script? Try specifying the full location to it.
3. Are you sure you have WRITE permissions on the script directory?

you need write permission for apache server. chmod 777 that directory.
0
 

Author Comment

by:COMPUTER_SC_STUDENT
ID: 10888188
1. Are you sure you have the "unzip" command? Try specifying the full location to it

How I can check if I have it or not plz let me know...

2 & 3 is ok .... but 1 I could not check
0
 
LVL 14

Expert Comment

by:ThG
ID: 10890858
this should give you a clue:
<?php
system("unzip --help 2>&1");
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Checkout Page Input Field not aligned 1 26
How do I fix this UPDATE error? 7 32
PHP Soap Server returning XML but < & > as &lt; / &gt; 9 47
JQuery Search Filter 2 32
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question