Solved

Zip files & PHP

Posted on 2004-04-21
15
253 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now