php - 为什么我无法在亚马逊 EC2 服务器上使用 php 上传超过 3 MB 的文件?

标签 php amazon-web-services amazon-ec2 file-upload

我正在使用带有 Linux 实例的 Amazon EC2 服务器。在我的项目中,用户可以上传视频。所以我使用php来上传文件。它可以在其他服务器上工作,但不能在亚马逊 ec2 服务器上工作。当我上传小于 1 mb 的文件时,它可以工作,但如果文件大小大于 3 mb,它就无法工作。我不知道在哪里设置上传大文件的权限。 我能做什么?

这是我的示例代码 -

 <?php
    $fileName = $_FILES["file1"]["name"]; // The file name
    $fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder
    $fileType = $_FILES["file1"]["type"]; // The type of file it is
    $fileSize = $_FILES["file1"]["size"]; // File size in bytes
    $fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true
    if (!$fileTmpLoc) { // if file not chosen
        echo "ERROR: Please browse for a file before clicking the upload button.";
        exit();
    }
    if(move_uploaded_file($fileTmpLoc, "test_uploads/$fileName")){
        echo "$fileName upload is complete";
    } else {
        echo "move_uploaded_file function failed";
    }
    ?>

最佳答案

在您的 php.ini 文件中搜索 upload_max_filesize并增加该值。如果我没记错的话默认是 2M。

关于php - 为什么我无法在亚马逊 EC2 服务器上使用 php 上传超过 3 MB 的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32420627/

相关文章:

c# - AWS API 网关签名

python - 通过 API Gateway 在 EC2 上运行函数

php - 如何在没有javascript的情况下获取父窗口的URL?

php - Symfony/Propel 和 MySQL 的问题

php - 在通过 php 执行 shell 脚本时将文件传输到远程机器时出现问题

amazon-web-services - 如何将大量停用词上传到 AWS Elasticsearch

css - Rails 4 : SASS background image works locally, 在 AWS 中失败

amazon-web-services - AWS EC2如何使用预先存在的EBS卷作为主可启动磁盘?

linux - 以非 root 用户身份在 UserData 中运行命令

php - 无法用冒号解析 xml 数据 (:) from response using getNamespaces()