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 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化