phil
phil

Reputation: 253

How to upload a file using box view api in php

I am trying to utilize in php uploading a file using box view api. I am using the library from box-view-api GitHub

Here is my code:

 <?php
require_once('repository_fns.php');
require 'lib/box-view-api.php';
require 'lib/box-view-document.php';

session_start();

$objid=$_GET['objid'];

$object_general=get_obj_general($objid);
$object_rights=get_obj_rights($objid);
$object_lifecycle=get_obj_lifecycle($objid);
$object_tech=get_obj_tech($objid);

do_html_header('', 'browse.css');
display_object_metadata($object_general, $object_rights, $object_lifecycle,   $object_tech);

$api_key = 'MY_KEY';
$box = new Box_View_API($api_key);

$doc = new Box_View_Document(array(
'name' => 'Geology of Canada',
'file_path' => '/uploads/Geology of Canada.docx',
));

$box->upload($doc);

display_file_page();

do_html_footer();
?>

But why am I getting an error message:

Fatal error: Uncaught exception 'Box_View_Exception' with message 'couldn't       open file "/uploads/Geology of Canada.docx"' in /home/ychenlucs15/public_html/lib/box-view-api.php:241 Stack trace: #0 /home/ychenlucs15/public_html/lib/box-view-api.php(456): Box_View_API->httpRequest(Array) #1 /home/ychenlucs15/public_html/show_object.php(28): Box_View_API->upload(Object(Box_View_Document)) #2 {main} thrown in /home/ychenlucs15/public_html/lib/box-view-api.php on line 241

Can someone show me how to implement it correctly with php? Thank you in advance.

Upvotes: 1

Views: 237

Answers (0)

Related Questions