I want to upload a file with a submit button : https://www.w3schools.com/php/php_file_upload.asp
I want to mix this tuto with a function who upload my file on Sharepoint.
My code
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload" accept=".xlsx">
<input type="submit" value="Upload File" onClick="sendRequest" name="submit">
</form>
<?php
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$guzzle = new \GuzzleHttp\Client();
function sendRequest(){
$file = $_FILES["fileToUpload"]["name"];
$accessToken = '$accessToken';
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createCollectionRequest("PUT", "/sites/site-id/drive/root:/Test/folder/$file:/content")
->upload($file);
}
?>
But i have an error 405, i don't know if is the best solution ? Maybe i need to make a javascript SDK instead a PHP SDK ?
Thank you for yours answers.