Upload Gravity Form files to OneDrive


I’ve been looking for an away of upload files from Gravity Form direct to the cloud on OneDrive.
And so far, I found some codes that could be useful:

 add_filter( 'gform_upload_path', function ( $path_info, $form_id ) {
        GFCommon::log_debug( "log_upload_path(): path_info for form #{$form_id} => " . print_r( $path_info, true ) );
        return $path_info;
    }, 1, 2 );

add_filter( 'gform_upload_path', 'change_upload_path', 10, 2 );
function change_upload_path( $path_info, $form_id ) {
   $path_info['path'] = '/home/public_html/yourdomainfolder/new/path/';
   $path_info['url'] = 'http://yourdomainhere.com/new/path/';
   return $path_info;

require_once 'functions.inc.php';
$token = skydrive_tokenstore::acquire_token(); // Call this function to grab a current access_token, or false if none is available.

if (!$token) { // If no token, prompt to login. Call skydrive_auth::build_oauth_url() to get the redirect URL.
       echo "<div>";
       echo "<img src='statics/key-icon.png'>&nbsp";
       echo "<a href='" . skydrive_auth::build_oauth_url() . "'>Login with SkyDrive</a></span>";
       echo "</div>";
} else {
       $sd = new skydrive($token);
       try {
           $response = $sd->put_file($_GET['folderid'], '/file/to/put');
           // File was uploaded, return metadata.
       } catch (Exception $e) {
           // An error occured, print HTTP status code and description.
           echo "Error: ".$e->getMessage();


Instead of my domain path I would like to point it to one folder on Onedrive and if possible, generate a new folder for each upload containing the current WooCommerce order number. I don’t have much experience with PHP so any useful help will be great!

one.marcos 2 months 0 Answers 12 views 0

Leave an answer