0

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.

CodeCabin
  • 166
  • 1
  • 11
  • looks like you have some limit set to 512k, check http://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size – Iłya Bursov Nov 01 '16 at 20:09
  • checking php.ini isn't enough. PHP settings can be overriden at the apache level (`php_value` in .htaccess/.conf) and runtime (`ini_set()`). You need to check `phpinfo()` in your upload script to get the in-effect settings. – Marc B Nov 01 '16 at 20:13
  • If you do not use `ajax` can you send the 5MB file data using normal post method on your server? – EhsanT Nov 01 '16 at 22:26
  • My post_max_upload and my upload_max_filesize are the same in phpinfo() as in my php.ini file. – CodeCabin Nov 01 '16 at 22:30

1 Answers1

1

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.

CodeCabin
  • 166
  • 1
  • 11