Bug #70406 [Opn->Spm]: UAPI's Fileman::upload_files

From: Date: Wed, 02 Sep 2015 16:33:54 +0000
Subject: Bug #70406 [Opn->Spm]: UAPI's Fileman::upload_files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195712@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70406&edit=1

 ID:                 70406
 Updated by:         requinix@php.net
 Reported by:        admin at angosso dot net
 Summary:            UAPI's Fileman::upload_files
-Status:             Open
+Status:             Spam
 Type:               Bug
 Package:            Safe Mode/open_basedir
 Operating System:   Linux; Windows; Mac
 PHP Version:        5.6.12
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2015-09-02 11:11:48] admin at angosso dot net

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 this bug report at https://bugs.php.net/bug.php?id=70406&edit=1


Thread (2 messages)

« previous php.bugs (#195712) next »