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.

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

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装