file_get_contents not working for cloud storage [closed]

时光毁灭记忆、已成空白 提交于 2020-01-25 08:28:26

问题


<?php
include'vendor\autoload.php';
define("PROJECT_ID", 'projectname');
define("BUCKET_NAME", 'bucketname');
$content=file_get_contents('C:\Users\Useraccount\PhpstormProjects\Projectname\filename.txt);
echo($content);
?>

This is the code that is working well on localhost but I am not able to get file contents on cloud storage. It simply shows me an empty page. Which are the possible solutions to this problem?


回答1:


You must get the url where the storage located online, example https://host.com/storage/mystorage/file.txt and store this on variable on php.

<?php
    $target_url = 'https://host.com/storage/mystorage/file.txt';

    echo file_get_contents($target_url);
?>


来源:https://stackoverflow.com/questions/50795642/file-get-contents-not-working-for-cloud-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!