-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in uploading a file to SharePoint using example provided #295
Comments
@jcarval I'm having the same issue, did you manage to solve this? |
@jcarval @jasgreen @vgrem But it shoud be The / in front of Web is missing so you get an invalid URL like _apiWeb instead of _api/Web If somebody can change this |
Looks like this code is now changed: phpSPO/src/SharePoint/File.php Lines 187 to 204 in e41cb80
phpSPO/src/SharePoint/File.php Lines 214 to 233 in e41cb80
Does this fix your issue @cmollink ? Though this was already patched in July 2022. Maybe it wasn't in the release you are running? Maybe you are still on the 2.x version (instead of say 3.1.1) |
I need to upload a file to share point and using example provided done this:
<?php
require_once 'vendor/autoload.php';
use Office365\GraphServiceClient;
use Office365\Runtime\Auth\AADTokenProvider;
use Office365\SharePoint\ListTemplateType;
use Office365\SharePoint\SPList;
use Office365\SharePoint\SPResourcePath;
$siteUrl = "https://novoscanais.sharepoint.com";
$relativeUrl = "/faturas";
$username = "[email protected]";
$password = "mysecret";
$credentials = new UserCredentials("{$username}", $password);
$client = (new ClientContext("{$siteUrl}{$relativeUrl}"))->withCredentials($credentials);
$caminho_site = getcwd();
$temp_folder = join(DIRECTORY_SEPARATOR, [$caminho_site,"download"] );
/////do upload
$file = "test.pdf";
$targetFolder = "{$relativeUrl}/Documentos Partilhados/boda";
$targetFile = $targetFolder ."/".$file;
$file_path = join(DIRECTORY_SEPARATOR, [$temp_folder,$file] );
$fileContent = file_get_contents($file_path);
Office365\SharePoint\File::saveBinary($client, $targetFile,$fileContent);
die("Not Working");
Got error:
Fatal error: Uncaught Office365\Runtime\Http\RequestException: {"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"pt-PT","value":"O ficheiro /faturas/Documentos Partilhados/boda/test.pdf n\u00e3o existe."}}} in C:\xampp\htdocs\sharep\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php on line 214
Translating the file "test.pdf" does not exist in folder... sure, I want to upload it
Office365\Runtime\Http\RequestException: {"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"pt-PT","value":"O ficheiro /faturas/Documentos Partilhados/boda/test.pdf n\u00e3o existe."}}} in C:\xampp\htdocs\sharep\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php on line 214
Using latest phpSPO, xampp for windows php7.4
Can someone point me what is wrong? I used the code from examples provided
Many thanks
The text was updated successfully, but these errors were encountered: