问题
<?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