title: Firebase Storage upload php
body: <p>I'm currently trying to upload to the Firebase Cloud Storage using php, but running into an issue.</p>
  
  <p>I have a form in html, that takes the uploaded file (in my case an image), and passes it to a php file.</p>
  
  <p>This image is very small, 12.8kB, and a JPEG image.</p>
  
  <p>The php file takes the image, and tries to upload it to the storage.
  My current php code is roughly:</p>
  
  <pre><code>$storage = new StorageClient(['projectId' =&gt; '&lt;my_project_id&gt; ']);
  $bucket = $storage-&gt;bucket('images');
  $bucket-&gt;upload($_FILES['imageToUpload']['tmp_name']);
  </code></pre>
  
  <p>I can get it to print the bucket name, and it's details, so I know it's not that part that is causing the error.  </p>
  
  <p>The error I get is,</p>
  
  <pre><code>Fatal error: Uncaught InvalidArgumentException: A name is required when data is of type string or null. 
  in /var/www/html/Images/vendor/google/cloud-storage/src/Bucket.php:258 
  Stack trace: #0 /var/www/html/Images/uploadImage.php(74): Google\Cloud\Storage\Bucket-&gt;upload('/tmp/phpA9SAM8') 
  #1 {main} thrown in /var/www/html/Images/vendor/google/cloud-storage/src/Bucket.php on line 258
  </code></pre>
  
  <p>Oh, I am also working on 16.04 Ubuntu if that matters, with apache2.  (But I've been able to upload to my own computer with php.  Just refactoring to use Firebase now)</p>
  
  <p>EDIT:
  When I've changed my code to be </p>
  
  <pre><code>$bucket-&gt;upload(
      file_get_contents($_FILES['imageToUpload']['tmp_name']),
      [
          'name' =&gt; $_FILES['imageToUpload']['name']
      ]
  );
  </code></pre>
  
  <p>I'm getting the error:</p>
  
  <pre><code>Fatal error: Uncaught Google\Cloud\Core\Exception\NotFoundException: { "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "Not Found" } ], "code": 404, "message": "Not Found" } } in /var/www/html/Images/vendor/google/cloud-core/src/RequestWrapper.php:263
   Stack trace: #0 /var/www/html/Images/vendor/google/cloud-core/src/RequestWrapper.php(168): Google\Cloud\Core\RequestWrapper-&gt;convertToGoogleException(Object(GuzzleHttp\Exception\ClientException)) 
  #1 /var/www/html/Images/vendor/google/cloud-core/src/Upload/MultipartUploader.php(64): Google\Cloud\Core\RequestWrapper-&gt;send(Object(GuzzleHttp\Psr7\Request), Array) 
  #2 /var/www/html/Images/vendor/google/cloud-storage/src/Bucket.php(268): Google\Cloud\Core\Upload\MultipartUploader-&gt;upload() 
  #3 /var/www/html/Images/uploadImage.php(75): Google\Cloud\Storage\Bucket-&gt;upload('/tmp/phpR2vYYg', Array) 
  #4 {main} thrown in /var/www/html/Images/vendor/google/cloud-core/src/RequestWrapper.php on line 263
  </code></pre>