我是php的初学者,我想学习如何使用php在Dropbox上传文件。这是我的代码。
<?php
include 'connection.php';
require 'app/start.php';
require 'app/dropbox_auth.php';
if(!isset($_SESSION))
{
session_start();
}
if (isset($_POST['submit'])) {
$load = "token/";
$load = $load . basename($_FILES["fileToUpload"]["name"]);
$upload_name = basename($_FILES["fileToUpload"]["name"]);
$client->uploadFile($upload_name,Dropbox\WriteMode::add(),$load);
}
?>
并显示:
Fatal error: Uncaught exception 'InvalidArgumentException' with message ''path': bad path: must start with "/": "Blog Topic List.docx"' in D:\xampp\htdocs\form2\lib\Dropbox\Path.php:169 Stack trace: #0 D:\xampp\htdocs\form2\lib\Dropbox\Client.php(276): Dropbox\Path::checkArgNonRoot('path', 'Blog Topic List...') #1 D:\xampp\htdocs\form2\submit.php(163): Dropbox\Client->uploadFile('Blog Topic List...', Object(Dropbox\WriteMode), 'token/Blog Topi...') #2 {main} thrown in D:\xampp\htdocs\form2\lib\Dropbox\Path.php on line 169
我的代码出现错误
答案 0 :(得分:0)
&#34;路径&#34;参数必须以/
开头在最后一行,改为
$client->uploadFile("/" . $upload_name,Dropbox\WriteMode::add(),$load);