[Webinar] Streamline your web hosting managementRegister Today

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

PHP unzip on IIS7 Windows server

All:

I am trying to unzip a .zip file on a server with the following PHP script

<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
    $zip->extractTo('/my/unarchive/dir/');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>

Open in new window


The code segment is generating the following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in test-unzip.php on line 4

I suspect this may be linux code and must be altered for a window server...

Any thoughts?
0
RustyRazor
Asked:
RustyRazor
  • 3
1 Solution
 
Lukasz ChmielewskiCommented:
What is your PHP version ? Isn't it 4.x ?
0
 
RustyRazorAuthor Commented:
PHP v5.3 under IIS7
0
 
RustyRazorAuthor Commented:
This works (must specify absolute Windows path)

<?php
$destinationPath=$_SERVER['DOCUMENT_ROOT'].'/my/unarchive/dir/';
$sourceFileName=$destinationPath.'test.zip';

$zip = new ZipArchive;
if ($zip->open($sourceFileName) === TRUE) {
    $zip->extractTo($destinationPath);
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>
0
 
RustyRazorAuthor Commented:
nobody else solved it
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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