PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Store an item

storeItem() method is used to upload or otherwise add files to the storage provider.

Example 96. Storing an item

<?php
$data 
file_get_contents('/my/local/dir/picture.jpg');
$returnedData $storage->storeItem('/my/remote/path/picture.jpg'$data);

An optional third parameter describes service-specific options.

Example 97. Storing an item with options

<?php
$data 
file_get_contents("/my/local/dir/picture.jpg");

// Use S3 bucket: myBucket
// Make this item publicly readable
$returnedData $storage->storeItem(
    
'/my/remote/path/picture.jpg',
    
$data,
    array(
        
Zend_Cloud_StorageService_Adapter_S3::BUCKET_NAME => "myBucket",
        
Zend_Cloud_StorageService_Adapter_S3::METADATA    => array(
            
Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ,
        )
    )
);

For service adapters that support streaming, data can also be a PHP stream (i.e. opened file).

Zend Framework