dqg63264 2016-03-29 13:42
浏览 91

FormData附加到$ _POST而不是$ _FILES?

I'm trying to implement an upload routine for huge files, for this I'm chunking the file and send chunk by chunk to server so far so good.

Now to identify the chunk-parts, I'm trying to send some more information than the pure filepart in FormData.

var xhr = new XMLHttpRequest();
xhr.open("POST", 'upload.php', true);

var formData = new FormData();
formData.append("chunkpart", blob); // blob is Blob() or BlobBuilder
formData.append("chunkNumber", sendCount); // sendCount is an integer
formData.append("maxChunks", Math.ceil(maxChunks)); // maxChunks is a floatingpoint
formData.append("fileID", fileID); // fileID is an almost unique string
xhr.send(formData);

On the php side the chunkpart is found in $_FILES however chunkNumber, maxChunks and fileID are found in $_POST.

My question here: Am I doing something wrong or did I just misunderstood how FormData works and how can I get it work like I expected?

  • 写回答

1条回答 默认 最新

  • doutun1362 2016-03-29 14:03
    关注

    This is simply how posted content works with BLOB data. It gets uploaded as a "file" in a multipart form post. In PHP this type of form data is in the $_FILES variable and not the $_POST.

    Is there some reason that you can't grab data from both $_POST and $_FILES? I do that regularly when processing posting form content that includes files/images.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题