SAE学习-使用SAE的Storage服务存储图片_PHP教程

WBOY
Lepaskan: 2016-07-13 17:17:14
asal
927 orang telah melayarinya

首先看一下SAE的storage服务内容:

SAE学习-使用SAE的Storage服务存储图片_PHP教程

 

<span <?<span php
</span><span //</span><span 从SAE的汇总信息拿到这2个key
//属性
//方法</span>
<span function</span> loadImagesByGroupName(<span $directoryname</span><span ) {
    
    </span><span $accessKey</span> = "your app's accessKey"<span ;
    </span><span $secretKey</span> = "your app's secretKey"<span ;
    </span><span $sae_storage</span> = <span new</span> SaeStorage(<span $accessKey</span>, <span $secretKey</span><span );
    </span><span $domainName</span> = "projectimages"<span ;
    </span><span $listfiles</span> = <span $sae_storage</span>->getListByPath(<span $domainName</span>, <span $directoryname</span><span );



    </span><span $files</span> = <span $listfiles</span>["files"<span ];

    </span><span $imageUrls</span> = <span array</span><span ();
    </span><span foreach</span> (<span $files</span> <span as</span> <span $imagefile</span><span ) {
        
        </span><span $tempName</span>=<span $directoryname</span> ."/". <span $imagefile</span>["Name"<span ];
        </span><span $imageUrl</span> = <span $sae_storage</span>->getUrl(<span $domainName</span>, <span $tempName</span><span );
        </span><span array_push</span>(<span $imageUrls</span>, <span $imageUrl</span><span );
    }
    
    </span><span return</span> <span $imageUrls</span><span ;
}
 </span><span //</span><span 测试方法
//try {
//   
//    $result = loadImagesByGroupName("cokegame");
//    print_r($result);
//} catch (Exception $e) {
//    echo "Error:" . $e->getMessage();
//}</span>
?></span>
Salin selepas log masuk

<span <span require_once</span> 'CustomImage.php'<span ;
</span><ul <span class</span>="itemImageList">
                    <?<span php
                    
                    </span><span $imagesUrls</span>=loadImagesByGroupName("cokegame"<span );
                    </span><span //</span><span 使用for对数组进行循环</span>
                    
                    <span for</span>(<span $i</span>=0;<span $i</span><<span count</span>(<span $imagesUrls</span>);<span $i</span>++<span )
                    {
                        </span>?>
                        <li>
                            <a href="javascript:void(0);" rel=""><img  src=<?php <span echo</span alt="SAE学习-使用SAE的Storage服务存储图片_PHP教程" > <span $imagesUrls</span>[<span $i</span>] ?> alt="Coke Gaming Zone Preview Image"></a>
                        </li>
                    <?<span php   
                        }
                    </span>?>
                <div <span class</span>="clearfix"></div>
            </ul></span>
Salin selepas log masuk

Salin selepas log masuk

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/626619.htmlTechArticle。 首先看一下SAE的storage服务内容: loadImagesByGroupName( = "your app's accessKey" = "your app's secretKey" = SaeStorage( , = "projectimages" = -getListByPath( , = ["f...
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan