apache AWS s3在本地主机上上传文件,但在真实的URL中不工作

unftdfkk  于 2023-03-13  发布在  Apache
关注(0)|答案(1)|浏览(163)
function setUploadAWS($ORIGEM, $DESTINO, $DIR) {

    $BUCKET = 'some-bucket';

    $ACCESS_KEY = "some-access-key";
    $SECRET_KEY = "some-secret-key";
    $credentials = new Aws\Credentials\Credentials($ACCESS_KEY, $SECRET_KEY);

    try {

        $s3 = new S3Client([
            'version'     => 'latest',
            'region'      => 'us-east-1',
            'credentials' => $credentials
        ]);

        $result = $s3->putObject([
            'Bucket'     => $BUCKET,
            'Key'        => $DIR . $DESTINO,
            'SourceFile' => $ORIGEM,
        ]);
    } catch (S3Exception $e) {
        echo $e->getMessage() . "\n";
    }

用于上传图片的aws代码可以通过localhost上传文件,但无法将文件上传到系统。

7eumitmz

7eumitmz1#

解决方案是将参数allow_url_fopenallow_url_include更改为 On

allow_url_fopen= On
allow_url_include= On

参数列于php.ini中。

Path = apache2/php.ini

相关问题