0

How can I open the document (.docx) in editable format ? When I upload the doc file it will successfully viewed in drive of microsoft business account?

$uri ='https://graph.microsoft.com/v1.0/me/drive/root:/roshan.docx:/content';
$headers = array( 'Content-Type: application/text', "Cache-Control: no- cache", "Pragma: no-cache", "Authorization: bearer ".$pppp ); 
$output = "";
$pointer = fopen($filpath, 'r+');
$stat = fstat($pointer);
$pointersize = $stat['size'];
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $pointer);
curl_setopt($ch, CURLOPT_INFILESIZE, (int) $pointersize);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
$output = curl_exec($ch);
$output = json_decode($output, true);
4
  • What do you mean by "open"? The document can be edited either locally in Word or any other online service like O365 or Drive.
    – fabrik
    Sep 11, 2018 at 10:31
  • i want to open the word doc into drive of word online.. Sep 11, 2018 at 10:33
  • $filepath = 'C:/abc.docx'; Sep 11, 2018 at 10:53
  • You might wanna look into relevant API Documentation.
    – fabrik
    Sep 13, 2018 at 6:24

1 Answer 1

0

Google Chrome has a free Extension, Office Editing for Docs, Sheets, and Slides.

This extension allows you to open MS .docx files within Drive and edit them without needing to convert them first.

If you want to use Graph API and programmatically open from a web app, you can take a look at this thread which covers how to do this. How to programmatically open a file located in OneDrive using desktop Word?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.