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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法