Attempting to upload a file
I'm attempting to upload a file using the following code:
$pi = pathinfo($fpImg);
$dirname = $pi['dirname'];
$basename = $pi['basename'];
$pf = PodioFile::upload($dirname, $basename);
I am using server-side authentication as follows:
define("REDIRECT_URI", 'http://pubvps.hidden.com/podiotest.php');
Podio::setup($client_id, $client_secret, array(
"session_manager" => "PodioBrowserSession"
));
But when it runs, I get the following error (after about 60 seconds of waiting):
Fatal error: Uncaught exception 'PodioConnectionError' with message 'Connection to Podio API failed: [52] Empty reply from server' in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php:259 Stack trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(352): Podio::request('POST', '/file/v2/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioFile.php(54): Podio::post('/file/v2/', Array, Array) #2 /home/avcorp/vhosts/pubvps/podiotest.php(104): PodioFile::upload('/home/avcorp/vh...', 'imgYlRPfq.png') #3 /home/avcorp/vhosts/pubvps/podiotest.php(70): set_profileimg(Object(PodioUserStatus), '/home/avcorp/vh...') #4 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 259
Also, the log files are empty (either that, or I don't know where they are supposed to be). I'm checking in vendor/podio/podio-php/log
Thanks.
-
I figured it out.
When PodioFile::upload() is called, "$filepath" must be the FULLPATH TO THE FILENAME, not just the "directory" the file is in.
Of course, this sort of error could be *easily* avoided if on the "documentation" page here: https://developers.podio.com/doc/files/upload-file-1004361
an EXAMPLE was presented showing actual "code" instead of this:
PodioFile::upload( $file_path, $file_name );
which is basically useless (I can get that much information by looking at PodioFile.php, which is how I solved the problem when I saw what it was doing...)
-
Glad you were able to get it working! In the future, API questions should be directed to Stack Overflow:
http://stackoverflow.com/questions/tagged/podio
This will be the best place to get help from other developers.
/Jacquelyn - Podio
Please sign in to leave a comment.
Comments
2 comments