Solved

Zip files & PHP

Posted on 2004-04-21
15
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple function not working 7 43
Make checkboxes execute queries on click 8 31
deprecated mysql extensions 1 22
assigning javascript variable to php variable 8 37
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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

735 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