1

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.

4
  • And my server is linux hosting, this should work right?
    – phil
    Commented Feb 24, 2015 at 4:20
  • 'file_path' => '/uploads/Geology of Canada.docx', try using a full server path instead 'file_path' => '/home/ychenlucs15/public_html/uploads/Geology of Canada.docx', and check for folder/file permissions. Commented Feb 24, 2015 at 4:22
  • Add error reporting to the top of your file(s) right after your opening PHP tag for example <?php error_reporting(E_ALL); ini_set('display_errors', 1); then the rest of your code, to see if it yields anything. Commented Feb 24, 2015 at 4:23
  • @Fred -ii- No error message this time! I will try to get the file to display next. Thank you!
    – phil
    Commented Feb 24, 2015 at 4:29

0

Your Answer

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

Browse other questions tagged or ask your own question.