简体   繁体   English

如何使用PHP在Dropbox中上传文件

[英]How to upload file in dropbox using PHP

Im beginner in php and I want to learn how to upload file in Dropbox using php. 我是php的初学者,我想学习如何使用php在Dropbox中上传文件。 Here is my code. 这是我的代码。

<?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);


}
?>

and its displaying this: 并显示以下内容:

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

Theres an error on my code 我的代码有错误

The "path" parameter must be started with / “ path”参数必须以/开头

On last line, change to 在最后一行,更改为

$client->uploadFile("/" . $upload_name,Dropbox\WriteMode::add(),$load);

Ref: https://www.dropbox.com/developers-v1/core/start/php 参考: https : //www.dropbox.com/developers-v1/core/start/php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM