0

I'm building a website for my band. However, as I don't want to be the only one maintaining the site, I want to allow the other members to contribute via a dropbox-folder.

I have received a direct download link from dropbox that zip's the whole folder. this links looks something like this: http://www.dropbox.com/sh/xxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyyyyyyy?dl=1

A folder test with 777 rights is available on the server side.

However the dropbox zip-file won't extract, and windows-created zip-file does.

<?php

echo PHP_OS.' PHP:'.phpversion();

echo '<br>starting download<br>';
$dbLink = 'http://www.dropbox.com/sh/xxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyyyyyyy?dl=1'

$success = file_put_contents("./test.zip", fopen($dbLink, 'r'));

if ($success === FALSE) {
    echo 'error storing zip';
} else {
    echo 'success storing zip';
}

echo '<br>';

$zip = new ZipArchive;
$result = $zip->open('./test.zip');


if ($result === TRUE) {

    echo 'opened zip<br>';

    $success = $zip->extractTo('./test/');

    if ($success === TRUE) {
        echo 'unzip complete';
    } else {
        echo 'unzip failed';
    }

    $zip->close();
} else {

    echo 'unable to open zip';
}

?>

I'd like to hear your thought on this.

Nick
  • 3,143
  • 20
  • 34
  • Please update your code to use less ambiguous logging (i.e., don't repeat 'ok' and 'failed' and then post your output. – Greg Jan 14 '15 at 22:12
  • It seems to me that this is a PHP bug. Using code very similar to this, I can unzip some zip files and not others (including the ones generated by Dropbox). – user94559 Jan 15 '15 at 00:35
  • @smarx hmm, that's interesting and annoying at the same time... are you using dropbox zip-files that contain subfolders? – Nick Jan 15 '15 at 07:47
  • The zip file I used did not contain subfolders. – user94559 Jan 15 '15 at 08:10
  • I tried that as well, unfortunately without any success. Do you know whether there is an alternative way to achieve what I want? – Nick Jan 15 '15 at 08:26

0 Answers0