Bug #70406 [NEW]: UAPI's Fileman::upload_files
| From: | admin at angosso dot net | Date: | Wed, 02 Sep 2015 11:11:53 +0000 |
| Subject: | Bug #70406 [NEW]: UAPI's Fileman::upload_files | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-195693@lists.php.net to get a copy of this message | ||
From: admin at angosso dot net
Operating system: Linux; Windows; Mac
PHP version: 5.6.12
Package: Safe Mode/open_basedir
Bug Type: Bug
Bug description:UAPI's Fileman::upload_files
Description:
------------
Function requires that i call it in a specific way to ensure that it
uploads the file correctly.
tools, or concepts: PHP
Servers that run cPanel version 11.42 or later.
Test script:
---------------
<?php
// Log everything during development.
// If i run this on the CLI, set 'display_errors = On' in php.ini.
error_reporting(E_ALL);
// Declare my username and password for authentication.
$username = 'angosson';
$password = 'xxxxx';
// Define the API call.
$cpanel_host = '/home/angosson/.../';
$request_uri =
"https://$exemple.net:2083/execute/Fileman/upload_files";
// Define the filename and destination.
$upload_file = realpath("/home/angosson/php/fileto.uploadâ);
$destination_dir = "public_html";
// Set up the payload to send to the server.
if( function_exists( 'curl_file_create' ) ) {
$cf = curl_file_create( $upload_file );
} else {
$cf = "@/".$upload_file;
}
$payload = array(
'dir' => urlencode( $destination_dir ),
'file-1' => $cf
);
// Set up the cURL request object.
$ch = curl_init( $request_uri );
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt( $ch, CURLOPT_USERPWD, $username . ':' . $password );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
// Set up a POST request with the payload.
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
// Make the call, and then terminate the cURL caller object.
$curl_response = curl_exec( $ch );
curl_close( $ch );
// Decode and validate output.
$response = json_decode( $curl_response );
if( empty( $response ) ) {
echo "The cURL call did not return valid JSON:\n";
die( $response );
} elseif ( !$response->status ) {
echo "The cURL call returned valid JSON, but reported errors:\n";
die( $response->errors[0] . "\n" );
}
// Print and exit.
die( print_r( $respons
Expected result:
----------------
Print the validated output and exit
--
Edit bug report at https://bugs.php.net/bug.php?id=70406&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70406&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70406&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70406&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70406&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70406&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70406&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70406&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70406&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70406&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70406&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70406&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70406&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70406&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70406&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70406&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70406&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70406&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70406&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70406&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70406&r=mysqlcfg