move_uploaded_file() 无法将文件移动到 Google App Engine (php 7.2) 上的 Google 存储
move_uploaded_file() could not move file to Google Storage on Google App Engine (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");
}
}
这是我在日志中看到的内容:
trying to move /tmp/php69rSck to
gs://my-project.appspot.com/uploadedfiles/sale-image-3-1545631667.1964.jpg
could not move the uploaded file
我如何确定失败的原因?
我想通了。我忘记启用 gs://
流包装器:
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient();
$storage->registerStreamWrapper();
$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");
}
}
这是我在日志中看到的内容:
trying to move /tmp/php69rSck to gs://my-project.appspot.com/uploadedfiles/sale-image-3-1545631667.1964.jpg
could not move the uploaded file
我如何确定失败的原因?
我想通了。我忘记启用 gs://
流包装器:
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient();
$storage->registerStreamWrapper();