繁体   English   中英

PHP - Amazon S3 - tpyo,无法从ubuntu服务器上传,但在本地工作正常

[英]PHP - Amazon S3 - tpyo, can't upload from ubuntu server but works fine on local

我希望用户通过表单上传图像,然后将其存储在临时文件夹中以调整大小并进行转换。 转换图像后,可以将其上传到Amazon S3服务器(我正在使用tpyo S3)。 代码在本地机器上运行得非常好,但是当它在我的Ubuntu EC2服务器上运行时,图像不会上传(即使它被转换)。 我尝试了不同的文件夹权限设置但没有改变这是我的代码:

    $dir = "/var/www/html/inventorymanager/imageupload/";

    //path to new file location
    $moved_file = $dir.$uploadedFileName;
    if(move_uploaded_file($tmpUploadedFile, $moved_file)) {
        chmod($moved_file, 0775);
    } else{
        echo "There was an error uploading the file, please try again!";
    }

    //amazon file to upload name: create random name for the file to upload to S3 server
    $amazonFileToUploadName = randomStringGen(30).".jpg";
    //upload resized image to S3 server
    S3::putObject(S3::inputFile($moved_file, false), "inventorymanager-huyvu",  $amazonFileToUploadName, S3::ACL_PUBLIC_READ);

    //delete processed file after it is uploaded
    unlink($moved_file);

哈。 我花了10个小时调试代码并尝试不同的上传方法后才发现解决方案。 我后来发现我的服务器没有安装CURL! 这个S3 tpyo类仅适用于安装的CURL。 希望这会有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM