My client is an entrepeneur and has no html knowledge. He has a website that was created with PHP on a linux shared hosting environment (basic package). On his site he wants to show his previous jobs with photos. But he complains he finds it to hard to login as admin and uploads those photos himself.
-now he asks me to write something easy for him so that the photos in his Dropbox account are uploaded on his site. I said OK :)
I created an admin page ( Here my client can choose which dropbox album he wants to download to his site. ) -I have used the dropbox api for php to locate his photo-albums. -I made a form where I list those albums with submit buttons that will do a POST-request(parameter = path to file on dropbox account).
Here is the code for that request:
if (isset($_POST['AlbumAdd'])) {
$name = $_POST['AlbumAdd'];
//echo "submitted: $name <br>";
$entry = getClient()->getMetadataWithChildren($name); //dropbox-sdk
if ($entry['is_dir']) {
//for now create file on localhost -> replace with ftp to upload on shared hosting site
if (!file_exists(__DIR__ . "/../examples/folder" . $name)) { //if !excists create folder on localhost
mkdir(__DIR__ . "/../examples/folder" . $name, 0777, true);
//echo "created " . $name . "on localhost";
}
foreach ($entry['contents'] as $child) {
$cp = $child['path'];
$size = $child['size'];
$cn = basename($cp);
echo "basename (cn)= " . $cn . " [$size] <br>";
if (!$child['is_dir']) //files only
{
//download from dropbox to localhost
getClient()->getFile($cp, fopen(__DIR__ . '/../examples/folder' . $cp, 'w+b'));
}
}
}
}
This works fine for small files, but throws this exception when the album is too large:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\dropbox-sdk-php-1.1.4\dropbox-sdk\Dropbox\CurlStreamRelay.php on line 26
TEST OUTPUT:
basename (cn)= 01.mp3 [8.1 MB]
basename (cn)= 02.mp3 [7.3 MB]
basename (cn)= 03.mp3 [6 MB]
What is the best thing to do now?? -Helpdesk of the hosting site says they can't change the setting of the maximum execution time. So there is no point in changing my php.ini file.
-upload each photo individually?
-switching to dedicated server means I have full control? I don't know if my client likes to pay 125€ extra/month