douningchang3610 2018-12-24 06:30
浏览 54
已采纳

move_uploaded_file()无法将文件移动到Google App Engine上的Google存储空间(php 7.2)

$filename = generate_filename($type, $id);
$filepath = "gs://$bucket.appspot.com/uploadedfiles/$filename";
error_log("trying to move ".$_FILES['image']['tmp_name']." to ".$filepath);
if (file_exists($_FILES['image']['tmp_name'])) {
    if (move_uploaded_file($_FILES['image']['tmp_name'], $filepath)) {
        // ...
    } else {
        error_log("could not move the uploaded file");
    }
}

This is what I'm seeing in the log:

trying to move /tmp/php69rSck to gs://my-project.appspot.com/uploadedfiles/sale-image-3-1545631667.1964.jpg

could not move the uploaded file

How can I determine why this is failing?

  • 写回答

1条回答 默认 最新

  • doulvyi2172 2018-12-25 17:27
    关注

    I figured out the problem. I had forgotten to enable the gs:// stream wrapper:

    require_once 'vendor/autoload.php';
    use Google\Cloud\Storage\StorageClient;
    
    $storage = new StorageClient();
    $storage->registerStreamWrapper();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示