duanhan8757 2016-11-01 20:05
浏览 1923
已采纳

通过POST请求上传大型base64图像时丢失信息

I am attempting to upload an image string(base64) and save it as an image server side.

The issue is that when I upload a large image(1200 px width jpg full quality) I lose some information as it's uploading.

My code works though because smaller images upload and save just fine.

I have already checked my ini php file and have max filesize upload and max post high enough that it really shouldn't be the issue (40 m).

My information gets passed along like this:

  • get base64 image data from phone camera (works, can display image client side)

  • place image data into a hidden form field (no information lost at this point)

  • send data through ajax POST request (no bugs or anything)

  • receive the image string from php POST variable (This is where I lose the information)

-- strlen before upload: 5,253,100

-- strlen after upload: 524,288

  • save image by using base64_decode (works fine, saves smaller images properly)

Now when I upload a larger image, I don't get any errors. The code still spits out a picture, but the picture is just the top quarter or so of the original image with the rest being grey.

I'd post some of my code but I'm fairly confident it isn't in my code since everything was working perfectly till I upped my image size. I am definitely losing the information at some point during the POST request.

Any tips to point me in the right direction would be lovely. Thanks for reading.

  • 写回答

1条回答 默认 最新

  • duannima8347 2016-11-04 17:46
    关注

    I've found the solution. It turns out that my data was getting cut off when I placed it inside a textbox. I didn't know textboxes had a maximum limit but in my case the textbox was truncating my data at 524288 characters.

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器