douzhai7873 2016-11-26 06:25
浏览 52
已采纳

PHP - 在Azure上大文件上载后$ _FILES为空

I've setup an Angular based file upload using the ng-file-upload plugin (https://github.com/danialfarid/ng-file-upload) and I've been handling the file upload with a PHP script.

The file upload and script work on smaller files (tested it on < 1MB), but fails on a larger file (9MB). This leads me to believe that there's a file upload issue. However, I've already created a .user.ini file in the /wwwroot folder with a single line:

upload_max_filesize=20M

Is there another reason why the $_FILES and $_POST arrays would be empty?

JS Code:

Upload.upload({
    url: '/scripts/receiveFile.php',
    file: file
}).then(function(resp) {
    console.log(resp.data);
}, function(resp) {
    console.log(resp.data);
}, function(evt) {
    var progressPercent = parseInt(100.0 * evt.loaded / evt.total);
    console.log(progressPercent + "%");
});

HTML Code:

<div>
    <h1>Upload</h1>
    <input type="file" accept=".zip" ngf-select="submitFile($file)"></input>
</div>

PHP Code:

$file_name = basename($_FILES['file']['name']);
$file_tmp_name = $_FILES['file']['tmp_name'];

The script fails because 'file' is undefined in the $_FILES array - because the $_FILES array is empty.

Thanks!

  • 写回答

1条回答 默认 最新

  • dsdt66064367 2016-11-26 06:33
    关注

    PHP has a confusing was of doing file uploads. To set a larger upload size, you should set both upload_max_filesize and post_max_size. These can be independently different values, as they do different things.

    post_max_size is the maximum file size that can be sent in a POST request to the PHP script. upload_max_filesize is the maximum file size allowed via any method.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决