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

通过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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?