Solved

Zip files & PHP

Posted on 2004-04-21
15
256 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 …

785 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