Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Zip files & PHP

How can I zip and unzip files using php ... Can any one give me a simple code plz
                    Thank you in advance,
0
COMPUTER_SC_STUDENT
Asked:
COMPUTER_SC_STUDENT
  • 3
  • 3
  • 3
  • +2
2 Solutions
 
mobanaCommented:
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
 
CosminBCommented:
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
 
CosminBCommented:
... sorry I've posted to the wrong question
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mobanaCommented:
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
 
COMPUTER_SC_STUDENTAuthor Commented:
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
 
CosminBCommented:
for 20 points ?!? :)
0
 
ThGCommented:
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
 
COMPUTER_SC_STUDENTAuthor Commented:
<?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
 
ThGCommented:
> 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
 
COMPUTER_SC_STUDENTAuthor Commented:
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
 
ThGCommented:
this should give you a clue:
<?php
system("unzip --help 2>&1");
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now