【发布时间】:2014-09-10 16:38:23
【问题描述】:
我尝试使用他们的 API 和 PHP 将文件上传到 DropBox。 就是代码:
require_once "dropbox/lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("app_info.json");
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$webAuth = new dbx\WebAuth($appInfo, "NoteBoxApp/0.01", "http://localhost/notes", $csrfTokenStore, null);
$title=$_POST["titulo"].".txt";
$nota=$_POST["conteudo"];
$accessToken=$_SESSION["token"];
$clientIdentifier=$_SESSION["userId"];
$client= new dbx\Client($accessToken, $clientIdentifier);
$file = fopen($title, "w") or die("Unable to open file!");
fwrite($file, $nota);
$stat = fstat($file);
$size = (int) $stat['size'];
$dropboxPath="/Aplicativos/Notes01";
try{
$metadata = $client->uploadFile($dropboxPath, dbx\WriteMode::add(), $file, $size);
}
catch(Exception $e) {
echo "Exceção: ", $e->getMessage(), "\n";
}
fclose($file);
我总是遇到异常
执行 HTTP 请求时出错:操作太慢。小于 1024 过去 10 秒传输的字节数/秒
我不明白为什么!我在本地主机上使用 XAMPP!... 提前感谢您的帮助!
【问题讨论】:
标签: php file upload timeout dropbox