Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to backup files from a specific directory to Dropbox using PHP only?
    primarykey
    data
    text
    <p>I would like to create a PHP script to backup files from a particular directory on my website to my Dropbox account.</p> <p>I tried to search for examples and how to work around it but I only found code to backup databases or to buy ready made solutions. </p> <p>This is the code I tried</p> <pre><code>&lt;?php $passw = "jason"; //change this to a password of your choice. if ($_POST) { require 'DropboxUploader.php'; try { // Rename uploaded file to reflect original name if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) throw new Exception('File was not successfully uploaded from your computer.'); $tmpDir = uniqid('/tmpCapes/'); if (!mkdir($tmpDir)) throw new Exception('Cannot create temporary directory!'); if ($_FILES['file']['name'] === "") throw new Exception('File name not supplied by the browser.'); $tmpFile = $tmpDir.'/'.str_replace("/\0", '_', $_FILES['file']['name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $tmpFile)) throw new Exception('Cannot rename uploaded file!'); if ($_POST['txtPassword'] != $passw) throw new Exception('Wrong Password'); // Upload $uploader = new DropboxUploader('user@example.com', 'password');// enter dropbox credentials $uploader-&gt;upload($tmpFile, $_POST['dest']); echo '&lt;span style="color: green;font-weight:bold;margin-left:393px;"&gt;File successfully uploaded to my Dropbox!&lt;/span&gt;'; } catch(Exception $e) { echo '&lt;span style="color: red;font-weight:bold;margin-left:393px;"&gt;Error: ' . htmlspecialchars($e-&gt;getMessage()) . '&lt;/span&gt;'; } // Clean up if (isset($tmpFile) &amp;&amp; file_exists($tmpFile)) unlink($tmpFile); if (isset($tmpDir) &amp;&amp; file_exists($tmpDir)) rmdir($tmpDir); } ?&gt; </code></pre> <p>But instead of uploading the image from my PC to Dropbox via my website. I want to modify the above code to copy files in a specific directory on my website to Dropbox.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload