Solved

PHP unzip on IIS7 Windows server

Posted on 2013-11-14
4
613 Views
Last Modified: 2013-11-20
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
Comment
Question by:RustyRazor
  • 3
4 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 39648882
What is your PHP version ? Isn't it 4.x ?
0
 

Author Comment

by:RustyRazor
ID: 39649117
PHP v5.3 under IIS7
0
 

Accepted Solution

by:
RustyRazor earned 0 total points
ID: 39652524
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
 

Author Closing Comment

by:RustyRazor
ID: 39662087
nobody else solved it
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Post a good COM tutorial 1 50
IIS Log files on Exchange 2013 server 6 85
powershell - detection of system errors 3 37
Creating csr file for SSL 4 48
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 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

23 Experts available now in Live!

Get 1:1 Help Now