file_get_contents无法用于云存储 [英] file_get_contents not working for cloud storage

查看:101
本文介绍了file_get_contents无法用于云存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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);
?>

这是在localhost上运行良好的代码,但是我无法在云存储上获取文件内容.它只是向我显示了一个空白页.该问题有哪些可能的解决方案?

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?

推荐答案

您必须获取在线存储所在的url,例如https://host.com/storage/mystorage/file.txt并将其存储在php的变量上.

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);
?>

这篇关于file_get_contents无法用于云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆