我正在使用带有 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/