PhpRiot
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

Store an item

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

Example 97. 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 98. 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