allow users to upload files to cloud storage in php

134 Views Asked by At

I have a website which allows users to login through google/facebook. I want that users upload files to my website which will be stored in cloud (ie. my Google Drive or Dropbox account). And only those files will be visible to them. Is it possible to achieve this? PLease help.

1

There are 1 best solutions below

0
DamiToma On

I suggest to create a database that will contain the usernames that will be able to download the file. I think that you create a $_SESSION['username'] variable (or something similar) to remember who's logged into your site. You just need to look into your database and verify if the person that is using yor website has the complete access to your files. For example :

<?php
$host = '';
$user = '';
$pass = '';
$database = '';
$conn = new mysqli($host,$user,$pass,$database);
$sql = "SELECT * FROM permission WHERE username='".$_SESSION['username']."'";
$result = $conn->query($sql);
if($result->num_rows > 0) {
    ---ALLOW USER TO DOWNLOAD---
} else {
    echo 'You're not allowed to download the file';
}
?>