user2288698
user2288698

Reputation:

Dropbox Api Upload Error

I am developing a app for my clients which allows to upload their files to dropbox.. i search the web and got some code the below is the code i got

<?php
if ($_POST) {
    require 'DropboxUploader.php';

    try {
        if ($_FILES['file']['error'] !== UPLOAD_ERR_OK)
            throw new Exception('File was not successfully uploaded from your computer.');

        if ($_FILES['file']['name'] === "")
            throw new Exception('File name not supplied by the browser.');

        // Upload
        $uploader = new DropboxUploader($_POST['email'], $_POST['password']);
        $uploader->upload($_FILES['file']['tmp_name'], $_POST['destination'], $_FILES['file']['name']);

        echo '<span style="color: green">File successfully uploaded to your Dropbox!</span>';
    } catch (Exception $e) {
        // Handle Upload Exceptions
        $label = ($e->getCode() & $uploader::FLAG_DROPBOX_GENERIC) ? 'DropboxUploader' : 'Exception';
        $error = sprintf("[%s] #%d %s", $label, $e->getCode(), $e->getMessage());

        echo '<span style="color: red">Error: ' . htmlspecialchars($error) . '</span>';
    }
}
?>
<form method="POST" enctype="multipart/form-data">
<dl>
<dt><label for="email">Dropbox e-mail</label></dt>
<dd><input type="text" id="email" name="email"></dd>
<dt><label for="password">Dropbox password</label></dt>
<dd><input type="password" id="password" name="password"></dd>
<dt><label for="destination">Destination directory (optional)</label></dt>
<dd><input type="text" id="destination" name="destination"> e.g. "dir/subdirectory", will be created if it
doesn't exist
</dd>
<dt><label for="file"></label>File</dt>
<dd><input type="file" id="file" name="file"></dd>
<dd><input type="submit" value="Upload the file to my Dropbox!"></dd>
</dl>
</form>

When i try to upload files using this script i get

Error: [DropboxUploader] #268697857 Curl error: (#60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

can any one help me in solving this issue.. and is there any api upload for skydrive and google drive

Upvotes: 1

Views: 1296

Answers (1)

Dannik
Dannik

Reputation: 90

open your DropboxUploader.php and:

  1. comment this:

    switch ($this->caCertSourceType) {
            case self::CACERT_SOURCE_FILE:
                curl_setopt($ch, CURLOPT_CAINFO, (string) $this->caCertSource);
                break;
            case self::CACERT_SOURCE_DIR:
                curl_setopt($ch, CURLOPT_CAPATH, (string) $this->caCertSource);
                break;
        }
    
  2. Add before:

    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
    
  3. Download and copy cacert.pm from http://curl.haxx.se/ca/cacert.pem in your folder.

It's done!

Upvotes: 3

Related Questions