6

I am uploading a file via ajax, an image specifically, and in my upload I am getting this information on the php server:

------WebKitFormBoundaryVuxuxnms21f4i1ZX Content-Disposition: form-data; name="file"; filename="blob" Content-Type: image/png

�PNG

IHDR,,y}�u IDATx^L�ɓdו�w|v�y�̈���b 8�ɪbUuw���h�Lfj-d2�i!3md���i�fZ���Z&�ꮪ& �C�������~��"�4gdF�?��s�{�w�sn�ٳ�A�<�Ͽ?��{��o���l4���G�Ջ��'q���x��ftzk�/w���D�������r�l�G�Q���fԪ�hԇ�Z����N7v�:����k����[�뱹�����vkQ���kFt[Q/����lT��x��k���Տ~��V�����N7�v{Q.բT*G� ------WebKitFormBoundaryVuxuxnms21f4i1ZX Content-Disposition: form-data; name="name"

image ------WebKitFormBoundaryVuxuxnms21f4i1ZX--

I know the charaters inside are the image/file being uploaded, but how do I parse the WebKitFormBoundary to only get the file data?

Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
  • Why would you want to “parse” anything yourself for a file upload? PHP does that for you automatically (when you use the right format for your upload) … http://www.php.net/manual/en/features.file-upload.php – CBroe Apr 12 '14 at 17:09
  • any solution to this? – Mubasshir Pawle Aug 17 '16 at 13:27
  • You should be able to receive uploaded file at server using $_FILE global variable of PHP. Once you got the file in it, you can move it to any location. The data you see above is basically header information + bytes for image file uploaded. Together they form a file. If you remove WebKitFormBoundary data, its just bytes and you wont be able to open it. – Satish Gadhave Dec 07 '17 at 19:12
  • check this https://stackoverflow.com/questions/5483851/manually-parse-raw-multipart-form-data-data-with-php – reshma Jun 29 '18 at 11:44

1 Answers1

-2

I had this problem, and fix it changing request method to 'POST', i hope this help!