Class 'google\\appengine\\CreateUploadURLReque

2019-02-28 04:41发布

问题:

i am using google cloud using CORE PHP to upload file using simple HTML Form But i am stuck on CloudStorageTools Class it throws continuous following error

Fatal error: Class 'google\appengine\api\cloud_storage\CloudStorageTools' not found

For Solve that i Included

include_once __DIR__ . '/vendor/autoload.php';
//Include class
require_once "google/appengine/api/cloud_storage/CloudStorageTools.php";

use google\appengine\api\cloud_storage\CloudStorageTools;

But than it throws second error. where am i going wrong in google cloud setup.

My full code looks like

$bucket = 'bucketname';
$root_path = 'gs://' . $bucket . '/';

$options = ['gs_bucket_name' => $bucket];
$upload_url = CloudStorageTools::createUploadUrl('/upload/handler', $options);

$_url = '';

if(isset($_POST['submit']))
{
  if(isset($_FILES['userfile']))
  {
    $name = $_FILES['userfile']['name'];
    $file_size =$_FILES['userfile']['size'];
    $file_tmp =$_FILES['userfile']['tmp_name'];
    $original = $root_path .$name;
    move_uploaded_file($file_tmp, $original);
    $_url=CloudStorageTools::getImageServingUrl($original);
  }
}