1

我正在导入文件,但我不知道如何导入整个文件夹或在 Dropbox 中创建一个我想知道如何将此导入文件夹而不是文件,以下是我使用的编码,需要更改或添加的内容这个?

这是upload.php

<?php 
require_once 'terceros/dropbox/vendor/autoload.php';
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;

$dropboxKey ="Key";
$dropboxSecret ="secret";
$dropboxToken="token";


$app = new DropboxApp($dropboxKey,$dropboxSecret,$dropboxToken);
$dropbox = new Dropbox($app);

if(!empty($_FILES)){
    $nombre = uniqid();
    $tempfile = $_FILES['file']['tmp_name'];
    $ext = explode(".",$_FILES['file']['name']);
    $ext = end($ext);
    $nombredropbox = "/" .$nombre . "." .$ext;

   try{
        $file = $dropbox->simpleUpload( $tempfile,$nombredropbox, ['autorename' => true]);
        echo "Arquivo enviado com sucesso";
   }catch(\exception $e){
        print_r($e);
        
   }



}


?>

这是 index.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>


<form action="upload.php" method="post" enctype="multipart/form-data" >


<input type="file" name="file" id="file"/>
<br>
<input type="submit" name="btnenviar" id="btnenviar" />

</form>
    
</body>
</html>

4

0 回答 0