N-Bomb(Nerd) Posted September 3, 2011 Share Posted September 3, 2011 Hello all, I'm having a bit of trouble here with my code. I'm trying to take an uploaded image and read the contents of the file and store that into my database for later use. I'm having some trouble with actually storing the content though. I'm using this to read the contents of the image file: $image_code = file_get_contents($image_file['tmp_name']); Which when echoing out $image_code I get the following result: �PNG IHDRPkoΒ��IDATx��\h���?�}�6��ڏ;7�f&�h��Dđ�A|��LMQ��E��D�JYP��Ȩ�SȢpa)��b�9e,���ܽ�����>{�_Ϲ�{����y���y=��9?��{m}}�s�Z�3��ql�5�b���(�c�_��Q9�|_�2�c����k�k���F?4��W�+r� ��*I��*++��o�t-���F:�-�U�ED��-�[�D�a�%B)4�/Ƙ\.�Lrť��C�x�ro!���[��BݻMs�E�d�_!�с��ӫ��^ґ(`�T'��XRL��d��RA� f{���R�.jLZJ_o� ��&B@�%>#�Q0���'�h� L�H*�ۣ��*%}cAP�hB �E�Ir;�+/W"�ҁM�^B�xm��ԗ�[ȣ�p�D6�,A�N6���.���jLnDG�p�R)ɗO��I_#-�R�q�5���(0�rר���&ķ ڪ` ~�z�;91"7��0\R��S�a���S["S B�!�B��(�Ҵ4a�h�"��į�(�Q�� �]5�(J�RAtx���Ӵ4 �#> ιT*%�dmHo�����:��QQ��)2m2#pZ�$|D��W��A0:P!�D�8����Ii�P,?�c��U:�� ��2a�e"��+�����)�����A�� ���V�5H2@�bD��R�I���"��lBKkT/�hcHzH�SK��f.�C�h���fԪ��vjrF���l�-�B��.�\*�Bt�6�XZ�!���DڋҞ� 0�8ȵN���M�(j�`���jk���Bw�#&I%�^�� �h��`W��֪-���I_L�r*���OעǤ�b���/4�*��|.�k�'lA �]'��hg��*ų��ja�IZꄇ:�q\�H�[�� ���o���"��B��0�M��r����A%E�4Zo�N��0�?)��,K�O�-a��[x��GĈ���x8|L�H��^3XH��s]�e��H`D ��NF�ІA_ObOi��>�����W 0�l$م�DΡ������� �Li;h��95��F�Ϻ�O��Z�l�<�S(e�dJ��{�z�F3�rq��-��[h=[j�Mh+F� m˱RLKNc��c��J������FzF���/��L24(�1tQr:��)��b����z�qA��Qwt�܇x�>&h���h\�Ҍ�azI?�B�24�$g��zFz�>Q���EBD�1����D����q0�&��p��%$6Cm1_X&N�3����\L'|�C:*�����C�P�\�>���`ђ����r��Y��C�r�DZۀ�2�̚�z�G�cE��tG�I���&Du�*�b�J�p6ʷɃ��}L�ilD���وY�x��#PP�J`K\�#{M�k�z(���Ma k�qؑ���0�K@�B�!�i� =m�.�D#���$g2 i養�J� �A���ME�#d�o$�$�e"�����F��G^ՙC*���tA��Q�S� �3��H,�S�Tyyysss:�8�A'hk�W''�$FLq�lCS��+�*��=�R�s�]w�\�������yΜ9ӧO_�t���mB�Χ6�{]��KN�X�y�Q�b)L�*��4a�s�=�v�Z���ehD �]l��KΙ)̈́�A#}Q�9C�F�i:��Q�Z�M3���Ŗ:� M�G!3��� � �6�9�N��]J��ݮ���&IW�Y`����l�$�����&��ZhH��"�� $S!+~ ҈������ީ��s.](�h���7��(]D���Y�H��a�r'> :&�E�N1)���կ��@8���}���S�I҄`5�PHd4EU�"b�:!Qd��1R0�iی�A��]�:����%%%������.\��lmm���>s���˗d�̝;wpp�?�Euq����y��UUU9�\�r�����q�6*XR�ԝw���������18��'��$Q'�E�=�����{�…KJJN�:�r���˗���;s��5�d��O>���7���{�~��ŋ{ }}};v�8|�P.����� 6�[�����>���{� �W������}�֭s��Uϟ?�gϞ����/�)ۑ�'"+��tvv�ɲdɒ���ꫯ�l6�{��7oR�O?�t���CCCT?<<|�}�yQ�L�������q�r�ȑ9s�d2�L&S[[[[[��d<l������W__��g2���:�(�R (�xTN�<���h�Ν%%%D������rUVV�y�f�����ٳ� �<��/��z�U�Vz��M�6m�$B$�q�)#�Le:�]�xq||�B!u�ӣ |��+V�������'O�2���SO���J@.]�����B���;w�lhh0 :i�[�ǖ�1����y�&iv�֭�g�u�0;v��������0c���G�-d�/555---��K/��o�8�zzz���Ф���~5�%}�#B~||�ƍ�����ׯ_�bŊ��.��f��>��u�8 ��sӦM+//��y��Q�������e˖G}���_��YD555���6嫯�jkk[�|�3g�)�V��U��]��SՇ/�4��f�z�̙�Ǐ�q|��4�ڵk?��1F�ŀ�ӧ{oDQt�ԩݻw/[�l۶m]]]���˾}�]��]JJJ�1˖-+**�Q���;66644��~Ԫ��iy:�h�M2RC�'F!��Sqa�ی�����{q��骪������J�����FQ7n�8w���0��PKK����'��ҵh�9�R�^��`�ʲ���7�Y�������X�(B�͛�*����^���f����~�����DE���'��B� p8��[�`��������Ъ{�����V���ù\��:::��f��Ijjj$S��Ȳ8���l$�[X�U2KO=�c__Y]]��g��+H2V��(���C�A"ߨׇE,?��n4!���.�^Q���~A�µrb>%4�����8�1k֬|p�…� �4�B1�X(nI9�(Jȅ��z�j����??��˗/�����ehh�3m�4A���'�1����3�>����c�Ykq�$}[[[��>@�z�cǎ9r�_���?~��t�O�"c��ӧ��W�~R��?�1ɌB��H��2Ƽ��ׯ_�X����Ժx���n��_���m߾]�Z�˗/o߾]��]���o�9Xc9���C��OZq�ܹ'_N�<|�ƣc��o��g�v�d�.n="">�ԙ,�VSeeez`���з�M}�f����^EJKA�c�#Pl���/� �4�AѺ��v���&� ѐ�jȰ��oX��!Y��tm�Ե�V�c�6�F���2t/�x�D��r9~>��1L2$pl�D��t�@}�i#BC����u#�|G~)�L3ȥ���+j�?�Q����V�^O�ɤ�y�����< �) L�/� T�L����r͠�t& ��cr��HX�yK�6���d�F��SC��D�WJ �#U��Ыq�?���WM�5�~3�@��Ï`҃i;���&i N��/��X�0��5���ThH,1��*K�B��N&�4|u��VÄ^���ue�IZ�up0r8��$]��q��.�=�����b<@��d�m�N��?4�����zZ��kk�N#���]d2�Gv�1�[���'��������D��Z�(�Kc �By�H���k.5}��BL���{J�\-�<h��� NN�A�*��40TL}rA�����I'WsU�Q&Q�\Ë��0�qr]bBd�! �$ 讅' b$�D+�Ћ�"�i�-pK��drb�,j�Hw���_�������:^�z�Vƍ�(UVV�_�$�KhCPKz;# ���� X�'dD��SK�r\D�)a#�t�b�pX���2��B�`F�&�A�kmtz���V͜t�Oq�Ͱ%�JF�WU��Buԓ��P�h�&��(��"9 B�O������pi)g}^��* ��PD_�|���"�~ �I2���7�&l�����E�J�!.��(�<��h3qu�f�%Bj��8���ϲ8J?%��ơ���R��.��EN'�^�j�'�L����Cm#�Xb��9�%�^RK�:��3�ǟ�zϘd�/"�=�~?@���ݩ���15c����ѥV�X�5�%�{I>�I�A���$��Vi�c��4�I�Q��%�6��:�и���2j�|�z�9Mҵ�Kk�OU0�Qw��:�'�o�4��4~��yDft%Om�tne�LS���ۉ��J�h��������=�r��Ɍg��I��)R�����X7�!~�孓e f3�#x���"Kr/*A8�K�J��?��.��<� (����0y��Ch�f�c�l���h�q$ e�xQ� ��A<�!��#���( ? ��1�[(���4:b��[�ZHIC�B��H��!@�: G" ���d��\�f8ʕ���(�q��+'4@Wj�)A�$�]� ��w/r��-�Fb[��7�]���mMp����L��Ω�h�(3ac S �.Hi���ߡ�iF^�"�Y`���-̱�J�����閬0"�IEND�B`� Which appears to be the actual content of the image file. From there I proceed to store it in my database (here's where I'm having the trouble): echo("<pre>" . $sv_item['video_image'] . "</pre>"); if($query = $db->connection->prepare("INSERT INTO sv_items (profile_id, video_name, uploader_name, video_image, video_image_type) VALUES (?, ?, ?, ?, ?)")) { $query->bind_param('sssbs', $profileId, $sv_item['video_name'], $sv_item['uploader_name'], $sv_item['video_image'], $sv_item['video_image_type']); $query->execute(); $query->close(); } The variable "$sv_item['video_image']" is the actual content of the image and as you can see before I insert it into the database I echo it out once more to verify and it is still the same content. The insert is a success and I check the database and the longblob (not sure if this needed to be longblob or not) size is 0 Bytes. I manually went into phpmyadmin and uploaded the file into the blob and it showed 79 KB so apparently doing it that way works. What am I doing wrong? -- Also, after uploading my image thru phpmyadmin I tried to query the database and echo out the results and I wasn't getting the same content that I put in.. I had an empty result. The query I was using I tested with the other fields and those all worked fine.. it's just the image code was an empty result. Ideas? Edit: Posting on here changes the image code, but I can assure you it's the correct file content. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 3, 2011 Author Share Posted September 3, 2011 I'm at a complete loss here Quote Link to comment Share on other sites More sharing options...
trq Posted September 3, 2011 Share Posted September 3, 2011 I'm not sure a simple file_get_contents call is binary safe. Use fopen and fread instead. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 3, 2011 Author Share Posted September 3, 2011 I'm not sure a simple file_get_contents call is binary safe. Use fopen and fread instead. I'm getting the same results using this code: if($file_handle = fopen($image_file['tmp_name'], 'rb')) { $image_content = fread($file_handle, filesize($image_file['tmp_name'])); fclose($file_handle); return $image_content; } It still echos out the image content before database insertion and it's still the same.. it is happening during some point in the database insertion. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 3, 2011 Author Share Posted September 3, 2011 I wasn't too clear in my last post. I was meaning to say that even though I'm using fopen and fread now that I'm still getting the same results as I was in the first post. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 3, 2011 Author Share Posted September 3, 2011 I still haven't been able to get this working and I've been trying this entire time. :-\ Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 4, 2011 Author Share Posted September 4, 2011 Anyone? Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 4, 2011 Author Share Posted September 4, 2011 I don't understand why this will not work. I'm doing everything I know and I still can't get it to work. If I'm able to echo out the contents before the database insertion then the only possible problem would be something that happens during the database insertion. Could someone at least tell me if what I'm doing is right? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 It would help if you posted the whole actual code that reproduces the problem (perhaps there is a bug in the mysqli prepared functions and someone could help you by actually reproducing or not reproducing the problem on a different system.) You are apparently using functions and could have a variable scope problem, the variable name you are using is changing at some point in your code, and I know of at least one case where using an array variable in a bind_param() statement that did not work. The out of context snippets of code don't actually help when you have a 'page of code' that does not do what you expect. And for the code you will post, are you still getting all but the image data being inserted into your database table and you know for a fact that you are not looking at an old row of data from some previous testing? Also, please post the database table definition. Edit: and also, what operating system/version, what php version, is php running as a server module or as a CGI application, and what mysql server version? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 Please use bbcode tags when posting code (using tags messes up all the white-space so that someone will be less likely to copy/test your code.) Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted September 4, 2011 Author Share Posted September 4, 2011 Also, in the sake of testing I empty the database after each attempt so I'm not looking at old results. When doing the database insertion the rest of the fields in the row get inserted just fine, but the image code isn't going into the database.. the blob is 0 Bytes. MySQL Version: 5.0 Here's the entire function that's doing the insert: function sv_Populate($sv_profile_name, $sv_list) { global $db; if(!$sv_profile_id = sv_ProfileExistsByName($sv_profile_name)) return false; //echo("<pre>" . print_r($sv_list, true) . "</pre>"); $sv_insert_errors = False; foreach($sv_list as $sv_item) { if($query = $db->connection->prepare("INSERT INTO sv_items (profile_id, video_name, uploader_name, video_image, video_image_type) VALUES (?, ?, ?, ?, ?)")) { $query->bind_param('sssbs', $sv_profile_id, $sv_item['video_name'], $sv_item['uploader_name'], $sv_item['video_image'], $sv_item['video_image_type']); $query->execute(); $sv_item_inserted = $query->affected_rows; $query->close(); } else { echo("QUERY ERROR!"); $sv_insert_errors = true; } if($sv_item_inserted >= 1) continue; else { echo("INSERT ERROR!"); $sv_insert_errors = true; } } if($sv_insert_errors == false) return true; return false; } As you can see from the commented line I've tried displaying the array of content and it all works perfectly (yes, it's all the same image): Array ( [1] => Array ( [video_name] => SV1 [uploader_name] => SVU1 [video_image] => �PNG IHDRPkoΒ��IDATx��\h���?�}�6��ڏ;7�f&�h��Dđ�A|��LMQ��E��D�JYP��Ȩ�SȢpa)��b�9e,���ܽ�����>{�_Ϲ�{����y���y=��9?��{m}}�s�Z�3��ql�5�b���(�c�_��Q9�|_�2�c����k�k���F?4��W�+r� ��*I��*++��o�t-���F:�-�U�ED��-�[�D�a�%B)4�/Ƙ\.�Lrť��C�x�ro!���[��BݻMs�E�d�_!�с��ӫ��^ґ(`�T'��XRL��d��RA� f{���R�.jLZJ_o� ��&B@�%>#�Q0���'�h� L�H*�ۣ��*%}cAP�hB �E�Ir;�+/W"�ҁM�^B�xm��ԗ�[ȣ�p�D6�,A�N6���.���jLnDG�p�R)ɗO��I_#-�R�q�5���(0�rר���&ķ ڪ` ~�z�;91"7��0\R��S�a���S["S B�!�B��(�Ҵ4a�h�"��į�(�Q�� �]5�(J�RAtx���Ӵ4 �#> ιT*%�dmHo�����:��QQ��)2m2#pZ�$|D��W��A0:P!�D�8����Ii�P,?�c��U:�� ��2a�e"��+�����)�����A�� ���V�5H2@�bD��R�I���"��lBKkT/�hcHzH�SK��f.�C�h���fԪ��vjrF���l�-�B��.�\*�Bt�6�XZ�!���DڋҞ� 0�8ȵN���M�(j�`���jk���Bw�#&I%�^�� �h��`W��֪-���I_L�r*���OעǤ�b���/4�*��|.�k�'lA �]'��hg��*ų��ja�IZꄇ:�q\�H�[�� ���o���"��B��0�M��r����A%E�4Zo�N��0�?)��,K�O�-a��[x��GĈ���x8|L�H��^3XH��s]�e��H`D ��NF�ІA_ObOi��>�����W 0�l$م�DΡ������� �Li;h��95��F�Ϻ�O��Z�l�<�S(e�dJ��{�z�F3�rq��-��[h=[j�Mh+F� m˱RLKNc��c��J������FzF���/��L24(�1tQr:��)��b����z�qA��Qwt�܇x�>&h���h\�Ҍ�azI?�B�24�$g��zFz�>Q���EBD�1����D����q0�&��p��%$6Cm1_X&N�3����\L'|�C:*�����C�P�\�>���`ђ����r��Y��C�r�DZۀ�2�̚�z�G�cE��tG�I���&Du�*�b�J�p6ʷɃ��}L�ilD���وY�x��#PP�J`K\�#{M�k�z(���Ma k�qؑ���0�K@�B�!�i� =m�.�D#���$g2 i養�J� �A���ME�#d�o$�$�e"�����F��G^ՙC*���tA��Q�S� �3��H,�S�Tyyysss:�8�A'hk�W''�$FLq�lCS��+�*��=�R�s�]w�\�������yΜ9ӧO_�t���mB�Χ6�{]��KN�X�y�Q�b)L�*��4a�s�=�v�Z���ehD �]l��KΙ)̈́�A#}Q�9C�F�i:��Q�Z�M3���Ŗ:� M�G!3��� � �6�9�N��]J��ݮ���&IW�Y`����l�$�����&��ZhH��"�� $S!+~ ҈������ީ��s.](�h���7��(]D���Y�H��a�r'> :&�E�N1)���կ��@8���}���S�I҄`5�PHd4EU�"b�:!Qd��1R0�iی�A��]�:����%%%������.\��lmm���>s���˗d�̝;wpp�?�Euq����y��UUU9�\�r�����q�6*XR�ԝw���������18��'��$Q'�E�=�����{�…KJJN�:�r���˗���;s��5�d��O>���7���{�~��ŋ{ }}};v�8|�P.����� 6�[�����>���{� �W������}�֭s��Uϟ?�gϞ����/�)ۑ�'"+��tvv�ɲdɒ���ꫯ�l6�{��7oR�O?�t���CCCT?<<|�}�yQ�L�������q�r�ȑ9s�d2�L&S[[[[[��d<l������W__��g2���:�(�R (�xTN�<���h�Ν%%%D������rUVV�y�f�����ٳ� �<��/��z�U�Vz��M�6m�$B$�q�)#�Le:�]�xq||�B!u�ӣ |��+V�������'O�2���SO���J@.]�����B���;w�lhh0 :i�[�ǖ�1����y�&iv�֭�g�u�0;v��������0c���G�-d�/555---��K/��o�8�zzz���Ф���~5�%}�#B~||�ƍ�����ׯ_�bŊ��.��f��>��u�8 ��sӦM+//��y��Q�������e˖G}���_��YD555���6嫯�jkk[�|�3g�)�V��U��]��SՇ/�4��f�z�̙�Ǐ�q|��4�ڵk?��1F�ŀ�ӧ{oDQt�ԩݻw/[�l۶m]]]���˾}�]��]JJJ�1˖-+**�Q���;66644��~Ԫ��iy:�h�M2RC�'F!��Sqa�ی�����{q��骪������J�����FQ7n�8w���0��PKK����'��ҵh�9�R�^��`�ʲ���7�Y�������X�(B�͛�*����^���f����~�����DE���'��B� p8��[�`��������Ъ{�����V���ù\��:::��f��Ijjj$S��Ȳ8���l$�[X�U2KO=�c__Y]]��g��+H2V��(���C�A"ߨׇE,?��n4!���.�^Q���~A�µrb>%4�����8�1k֬|p�…� �4�B1�X(nI9�(Jȅ��z�j����??��˗/�����ehh�3m�4A���'�1����3�>����c�Ykq�$}[[[��>@�z�cǎ9r�_���?~��t�O�"c��ӧ��W�~R��?�1ɌB��H��2Ƽ��ׯ_�X����Ժx���n��_���m߾]�Z�˗/o߾]��]���o�9Xc9���C��OZq�ܹ'_N�<|�ƣc��o��g�v�d�.n="">�ԙ,�VSeeez`���з�M}�f����^EJKA�c�#Pl���/� �4�AѺ��v���&� ѐ�jȰ��oX��!Y��tm�Ե�V�c�6�F���2t/�x�D��r9~>��1L2$pl�D��t�@}�i#BC����u#�|G~)�L3ȥ���+j�?�Q����V�^O�ɤ�y�����< �) L�/� T�L����r͠�t& ��cr��HX�yK�6���d�F��SC��D�WJ �#U��Ыq�?���WM�5�~3�@��Ï`҃i;���&i N��/��X�0��5���ThH,1��*K�B��N&�4|u��VÄ^���ue�IZ�up0r8��$]��q��.�=�����b<@��d�m�N��?4�����zZ��kk�N#���]d2�Gv�1�[���'��������D��Z�(�Kc �By�H���k.5}��BL���{J�\-�<h��� NN�A�*��40TL}rA�����I'WsU�Q&Q�\Ë��0�qr]bBd�! �$ 讅' b$�D+�Ћ�"�i�-pK��drb�,j�Hw���_�������:^�z�Vƍ�(UVV�_�$�KhCPKz;# ���� X�'dD��SK�r\D�)a#�t�b�pX���2��B�`F�&�A�kmtz���V͜t�Oq�Ͱ%�JF�WU��Buԓ��P�h�&��(��"9 B�O������pi)g}^��* ��PD_�|���"�~ �I2���7�&l�����E�J�!.��(�<��h3qu�f�%Bj��8���ϲ8J?%��ơ���R��.��EN'�^�j�'�L����Cm#�Xb��9�%�^RK�:��3�ǟ�zϘd�/"�=�~?@���ݩ���15c����ѥV�X�5�%�{I>�I�A���$��Vi�c��4�I�Q��%�6��:�и���2j�|�z�9Mҵ�Kk�OU0�Qw��:�'�o�4��4~��yDft%Om�tne�LS���ۉ��J�h��������=�r��Ɍg��I��)R�����X7�!~�孓e f3�#x���"Kr/*A8�K�J��?��.��<� (����0y��Ch�f�c�l���h�q$ e�xQ� ��A<�!��#���( ? ��1�[(���4:b��[�ZHIC�B��H��!@�: G" ���d��\�f8ʕ���(�q��+'4@Wj�)A�$�]� ��w/r��-�Fb[��7�]���mMp����L��Ω�h�(3ac S �.Hi���ߡ�iF^�"�Y`���-̱�J�����閬0"�IEND�B`� [video_image_type] => png ) [2] => Array ( [video_name] => SV2 [uploader_name] => SVU2 [video_image] => �PNG IHDRPkoΒ��IDATx��\h���?�}�6��ڏ;7�f&�h��Dđ�A|��LMQ��E��D�JYP��Ȩ�SȢpa)��b�9e,���ܽ�����>{�_Ϲ�{����y���y=��9?��{m}}�s�Z�3��ql�5�b���(�c�_��Q9�|_�2�c����k�k���F?4��W�+r� ��*I��*++��o�t-���F:�-�U�ED��-�[�D�a�%B)4�/Ƙ\.�Lrť��C�x�ro!���[��BݻMs�E�d�_!�с��ӫ��^ґ(`�T'��XRL��d��RA� f{���R�.jLZJ_o� ��&B@�%>#�Q0���'�h� L�H*�ۣ��*%}cAP�hB �E�Ir;�+/W"�ҁM�^B�xm��ԗ�[ȣ�p�D6�,A�N6���.���jLnDG�p�R)ɗO��I_#-�R�q�5���(0�rר���&ķ ڪ` ~�z�;91"7��0\R��S�a���S["S B�!�B��(�Ҵ4a�h�"��į�(�Q�� �]5�(J�RAtx���Ӵ4 �#> ιT*%�dmHo�����:��QQ��)2m2#pZ�$|D��W��A0:P!�D�8����Ii�P,?�c��U:�� ��2a�e"��+�����)�����A�� ���V�5H2@�bD��R�I���"��lBKkT/�hcHzH�SK��f.�C�h���fԪ��vjrF���l�-�B��.�\*�Bt�6�XZ�!���DڋҞ� 0�8ȵN���M�(j�`���jk���Bw�#&I%�^�� �h��`W��֪-���I_L�r*���OעǤ�b���/4�*��|.�k�'lA �]'��hg��*ų��ja�IZꄇ:�q\�H�[�� ���o���"��B��0�M��r����A%E�4Zo�N��0�?)��,K�O�-a��[x��GĈ���x8|L�H��^3XH��s]�e��H`D ��NF�ІA_ObOi��>�����W 0�l$م�DΡ������� �Li;h��95��F�Ϻ�O��Z�l�<�S(e�dJ��{�z�F3�rq��-��[h=[j�Mh+F� m˱RLKNc��c��J������FzF���/��L24(�1tQr:��)��b����z�qA��Qwt�܇x�>&h���h\�Ҍ�azI?�B�24�$g��zFz�>Q���EBD�1����D����q0�&��p��%$6Cm1_X&N�3����\L'|�C:*�����C�P�\�>���`ђ����r��Y��C�r�DZۀ�2�̚�z�G�cE��tG�I���&Du�*�b�J�p6ʷɃ��}L�ilD���وY�x��#PP�J`K\�#{M�k�z(���Ma k�qؑ���0�K@�B�!�i� =m�.�D#���$g2 i養�J� �A���ME�#d�o$�$�e"�����F��G^ՙC*���tA��Q�S� �3��H,�S�Tyyysss:�8�A'hk�W''�$FLq�lCS��+�*��=�R�s�]w�\�������yΜ9ӧO_�t���mB�Χ6�{]��KN�X�y�Q�b)L�*��4a�s�=�v�Z���ehD �]l��KΙ)̈́�A#}Q�9C�F�i:��Q�Z�M3���Ŗ:� M�G!3��� � �6�9�N��]J��ݮ���&IW�Y`����l�$�����&��ZhH��"�� $S!+~ ҈������ީ��s.](�h���7��(]D���Y�H��a�r'> :&�E�N1)���կ��@8���}���S�I҄`5�PHd4EU�"b�:!Qd��1R0�iی�A��]�:����%%%������.\��lmm���>s���˗d�̝;wpp�?�Euq����y��UUU9�\�r�����q�6*XR�ԝw���������18��'��$Q'�E�=�����{�…KJJN�:�r���˗���;s��5�d��O>���7���{�~��ŋ{ }}};v�8|�P.����� 6�[�����>���{� �W������}�֭s��Uϟ?�gϞ����/�)ۑ�'"+��tvv�ɲdɒ���ꫯ�l6�{��7oR�O?�t���CCCT?<<|�}�yQ�L�������q�r�ȑ9s�d2�L&S[[[[[��d<l������W__��g2���:�(�R (�xTN�<���h�Ν%%%D������rUVV�y�f�����ٳ� �<��/��z�U�Vz��M�6m�$B$�q�)#�Le:�]�xq||�B!u�ӣ |��+V�������'O�2���SO���J@.]�����B���;w�lhh0 :i�[�ǖ�1����y�&iv�֭�g�u�0;v��������0c���G�-d�/555---��K/��o�8�zzz���Ф���~5�%}�#B~||�ƍ�����ׯ_�bŊ��.��f��>��u�8 ��sӦM+//��y��Q�������e˖G}���_��YD555���6嫯�jkk[�|�3g�)�V��U��]��SՇ/�4��f�z�̙�Ǐ�q|��4�ڵk?��1F�ŀ�ӧ{oDQt�ԩݻw/[�l۶m]]]���˾}�]��]JJJ�1˖-+**�Q���;66644��~Ԫ��iy:�h�M2RC�'F!��Sqa�ی�����{q��骪������J�����FQ7n�8w���0��PKK����'��ҵh�9�R�^��`�ʲ���7�Y�������X�(B�͛�*����^���f����~�����DE���'��B� p8��[�`��������Ъ{�����V���ù\��:::��f��Ijjj$S��Ȳ8���l$�[X�U2KO=�c__Y]]��g��+H2V��(���C�A"ߨׇE,?��n4!���.�^Q���~A�µrb>%4�����8�1k֬|p�…� �4�B1�X(nI9�(Jȅ��z�j����??��˗/�����ehh�3m�4A���'�1����3�>����c�Ykq�$}[[[��>@�z�cǎ9r�_���?~��t�O�"c��ӧ��W�~R��?�1ɌB��H��2Ƽ��ׯ_�X����Ժx���n��_���m߾]�Z�˗/o߾]��]���o�9Xc9���C��OZq�ܹ'_N�<|�ƣc��o��g�v�d�.n="">�ԙ,�VSeeez`���з�M}�f����^EJKA�c�#Pl���/� �4�AѺ��v���&� ѐ�jȰ��oX��!Y��tm�Ե�V�c�6�F���2t/�x�D��r9~>��1L2$pl�D��t�@}�i#BC����u#�|G~)�L3ȥ���+j�?�Q����V�^O�ɤ�y�����< �) L�/� T�L����r͠�t& ��cr��HX�yK�6���d�F��SC��D�WJ �#U��Ыq�?���WM�5�~3�@��Ï`҃i;���&i N��/��X�0��5���ThH,1��*K�B��N&�4|u��VÄ^���ue�IZ�up0r8��$]��q��.�=�����b<@��d�m�N��?4�����zZ��kk�N#���]d2�Gv�1�[���'��������D��Z�(�Kc �By�H���k.5}��BL���{J�\-�<h��� NN�A�*��40TL}rA�����I'WsU�Q&Q�\Ë��0�qr]bBd�! �$ 讅' b$�D+�Ћ�"�i�-pK��drb�,j�Hw���_�������:^�z�Vƍ�(UVV�_�$�KhCPKz;# ���� X�'dD��SK�r\D�)a#�t�b�pX���2��B�`F�&�A�kmtz���V͜t�Oq�Ͱ%�JF�WU��Buԓ��P�h�&��(��"9 B�O������pi)g}^��* ��PD_�|���"�~ �I2���7�&l�����E�J�!.��(�<��h3qu�f�%Bj��8���ϲ8J?%��ơ���R��.��EN'�^�j�'�L����Cm#�Xb��9�%�^RK�:��3�ǟ�zϘd�/"�=�~?@���ݩ���15c����ѥV�X�5�%�{I>�I�A���$��Vi�c��4�I�Q��%�6��:�и���2j�|�z�9Mҵ�Kk�OU0�Qw��:�'�o�4��4~��yDft%Om�tne�LS���ۉ��J�h��������=�r��Ɍg��I��)R�����X7�!~�孓e f3�#x���"Kr/*A8�K�J��?��.��<� (����0y��Ch�f�c�l���h�q$ e�xQ� ��A<�!��#���( ? ��1�[(���4:b��[�ZHIC�B��H��!@�: G" ���d��\�f8ʕ���(�q��+'4@Wj�)A�$�]� ��w/r��-�Fb[��7�]���mMp����L��Ω�h�(3ac S �.Hi���ߡ�iF^�"�Y`���-̱�J�����閬0"�IEND�B`� [video_image_type] => png ) [3] => Array ( [video_name] => SV3 [uploader_name] => SVU3 [video_image] => �PNG IHDRPkoΒ��IDATx��\h���?�}�6��ڏ;7�f&�h��Dđ�A|��LMQ��E��D�JYP��Ȩ�SȢpa)��b�9e,���ܽ�����>{�_Ϲ�{����y���y=��9?��{m}}�s�Z�3��ql�5�b���(�c�_��Q9�|_�2�c����k�k���F?4��W�+r� ��*I��*++��o�t-���F:�-�U�ED��-�[�D�a�%B)4�/Ƙ\.�Lrť��C�x�ro!���[��BݻMs�E�d�_!�с��ӫ��^ґ(`�T'��XRL��d��RA� f{���R�.jLZJ_o� ��&B@�%>#�Q0���'�h� L�H*�ۣ��*%}cAP�hB �E�Ir;�+/W"�ҁM�^B�xm��ԗ�[ȣ�p�D6�,A�N6���.���jLnDG�p�R)ɗO��I_#-�R�q�5���(0�rר���&ķ ڪ` ~�z�;91"7��0\R��S�a���S["S B�!�B��(�Ҵ4a�h�"��į�(�Q�� �]5�(J�RAtx���Ӵ4 �#> ιT*%�dmHo�����:��QQ��)2m2#pZ�$|D��W��A0:P!�D�8����Ii�P,?�c��U:�� ��2a�e"��+�����)�����A�� ���V�5H2@�bD��R�I���"��lBKkT/�hcHzH�SK��f.�C�h���fԪ��vjrF���l�-�B��.�\*�Bt�6�XZ�!���DڋҞ� 0�8ȵN���M�(j�`���jk���Bw�#&I%�^�� �h��`W��֪-���I_L�r*���OעǤ�b���/4�*��|.�k�'lA �]'��hg��*ų��ja�IZꄇ:�q\�H�[�� ���o���"��B��0�M��r����A%E�4Zo�N��0�?)��,K�O�-a��[x��GĈ���x8|L�H��^3XH��s]�e��H`D ��NF�ІA_ObOi��>�����W 0�l$م�DΡ������� �Li;h��95��F�Ϻ�O��Z�l�<�S(e�dJ��{�z�F3�rq��-��[h=[j�Mh+F� m˱RLKNc��c��J������FzF���/��L24(�1tQr:��)��b����z�qA��Qwt�܇x�>&h���h\�Ҍ�azI?�B�24�$g��zFz�>Q���EBD�1����D����q0�&��p��%$6Cm1_X&N�3����\L'|�C:*�����C�P�\�>���`ђ����r��Y��C�r�DZۀ�2�̚�z�G�cE��tG�I���&Du�*�b�J�p6ʷɃ��}L�ilD���وY�x��#PP�J`K\�#{M�k�z(���Ma k�qؑ���0�K@�B�!�i� =m�.�D#���$g2 i養�J� �A���ME�#d�o$�$�e"�����F��G^ՙC*���tA��Q�S� �3��H,�S�Tyyysss:�8�A'hk�W''�$FLq�lCS��+�*��=�R�s�]w�\�������yΜ9ӧO_�t���mB�Χ6�{]��KN�X�y�Q�b)L�*��4a�s�=�v�Z���ehD �]l��KΙ)̈́�A#}Q�9C�F�i:��Q�Z�M3���Ŗ:� M�G!3��� � �6�9�N��]J��ݮ���&IW�Y`����l�$�����&��ZhH��"�� $S!+~ ҈������ީ��s.](�h���7��(]D���Y�H��a�r'> :&�E�N1)���կ��@8���}���S�I҄`5�PHd4EU�"b�:!Qd��1R0�iی�A��]�:����%%%������.\��lmm���>s���˗d�̝;wpp�?�Euq����y��UUU9�\�r�����q�6*XR�ԝw���������18��'��$Q'�E�=�����{�…KJJN�:�r���˗���;s��5�d��O>���7���{�~��ŋ{ }}};v�8|�P.����� 6�[�����>���{� �W������}�֭s��Uϟ?�gϞ����/�)ۑ�'"+��tvv�ɲdɒ���ꫯ�l6�{��7oR�O?�t���CCCT?<<|�}�yQ�L�������q�r�ȑ9s�d2�L&S[[[[[��d<l������W__��g2���:�(�R (�xTN�<���h�Ν%%%D������rUVV�y�f�����ٳ� �<��/��z�U�Vz��M�6m�$B$�q�)#�Le:�]�xq||�B!u�ӣ |��+V�������'O�2���SO���J@.]�����B���;w�lhh0 :i�[�ǖ�1����y�&iv�֭�g�u�0;v��������0c���G�-d�/555---��K/��o�8�zzz���Ф���~5�%}�#B~||�ƍ�����ׯ_�bŊ��.��f��>��u�8 ��sӦM+//��y��Q�������e˖G}���_��YD555���6嫯�jkk[�|�3g�)�V��U��]��SՇ/�4��f�z�̙�Ǐ�q|��4�ڵk?��1F�ŀ�ӧ{oDQt�ԩݻw/[�l۶m]]]���˾}�]��]JJJ�1˖-+**�Q���;66644��~Ԫ��iy:�h�M2RC�'F!��Sqa�ی�����{q��骪������J�����FQ7n�8w���0��PKK����'��ҵh�9�R�^��`�ʲ���7�Y�������X�(B�͛�*����^���f����~�����DE���'��B� p8��[�`��������Ъ{�����V���ù\��:::��f��Ijjj$S��Ȳ8���l$�[X�U2KO=�c__Y]]��g��+H2V��(���C�A"ߨׇE,?��n4!���.�^Q���~A�µrb>%4�����8�1k֬|p�…� �4�B1�X(nI9�(Jȅ��z�j����??��˗/�����ehh�3m�4A���'�1����3�>����c�Ykq�$}[[[��>@�z�cǎ9r�_���?~��t�O�"c��ӧ��W�~R��?�1ɌB��H��2Ƽ��ׯ_�X����Ժx���n��_���m߾]�Z�˗/o߾]��]���o�9Xc9���C��OZq�ܹ'_N�<|�ƣc��o��g�v�d�.n="">�ԙ,�VSeeez`���з�M}�f����^EJKA�c�#Pl���/� �4�AѺ��v���&� ѐ�jȰ��oX��!Y��tm�Ե�V�c�6�F���2t/�x�D��r9~>��1L2$pl�D��t�@}�i#BC����u#�|G~)�L3ȥ���+j�?�Q����V�^O�ɤ�y�����< �) L�/� T�L����r͠�t& ��cr��HX�yK�6���d�F��SC��D�WJ �#U��Ыq�?���WM�5�~3�@��Ï`҃i;���&i N��/��X�0��5���ThH,1��*K�B��N&�4|u��VÄ^���ue�IZ�up0r8��$]��q��.�=�����b<@��d�m�N��?4�����zZ��kk�N#���]d2�Gv�1�[���'��������D��Z�(�Kc �By�H���k.5}��BL���{J�\-�<h��� NN�A�*��40TL}rA�����I'WsU�Q&Q�\Ë��0�qr]bBd�! �$ 讅' b$�D+�Ћ�"�i�-pK��drb�,j�Hw���_�������:^�z�Vƍ�(UVV�_�$�KhCPKz;# ���� X�'dD��SK�r\D�)a#�t�b�pX���2��B�`F�&�A�kmtz���V͜t�Oq�Ͱ%�JF�WU��Buԓ��P�h�&��(��"9 B�O������pi)g}^��* ��PD_�|���"�~ �I2���7�&l�����E�J�!.��(�<��h3qu�f�%Bj��8���ϲ8J?%��ơ���R��.��EN'�^�j�'�L����Cm#�Xb��9�%�^RK�:��3�ǟ�zϘd�/"�=�~?@���ݩ���15c����ѥV�X�5�%�{I>�I�A���$��Vi�c��4�I�Q��%�6��:�и���2j�|�z�9Mҵ�Kk�OU0�Qw��:�'�o�4��4~��yDft%Om�tne�LS���ۉ��J�h��������=�r��Ɍg��I��)R�����X7�!~�孓e f3�#x���"Kr/*A8�K�J��?��.��<� (����0y��Ch�f�c�l���h�q$ e�xQ� ��A<�!��#���( ? ��1�[(���4:b��[�ZHIC�B��H��!@�: G" ���d��\�f8ʕ���(�q��+'4@Wj�)A�$�]� ��w/r��-�Fb[��7�]���mMp����L��Ω�h�(3ac S �.Hi���ߡ�iF^�"�Y`���-̱�J�����閬0"�IEND�B`� [video_image_type] => png ) [4] => Array ( [video_name] => SV44 [uploader_name] => SVU4 [video_image] => �PNG IHDRPkoΒ��IDATx��\h���?�}�6��ڏ;7�f&�h��Dđ�A|��LMQ��E��D�JYP��Ȩ�SȢpa)��b�9e,���ܽ�����>{�_Ϲ�{����y���y=��9?��{m}}�s�Z�3��ql�5�b���(�c�_��Q9�|_�2�c����k�k���F?4��W�+r� ��*I��*++��o�t-���F:�-�U�ED��-�[�D�a�%B)4�/Ƙ\.�Lrť��C�x�ro!���[��BݻMs�E�d�_!�с��ӫ��^ґ(`�T'��XRL��d��RA� f{���R�.jLZJ_o� I had to take out some of the array because I hit a max character limit in my post I believe, but the rest of the array is there I can assure you. Quote Link to comment Share on other sites More sharing options...
jcbones Posted September 4, 2011 Share Posted September 4, 2011 I believe you should be using send_long_data() for this operation. Quote Link to comment Share on other sites More sharing options...
mat3000000 Posted September 4, 2011 Share Posted September 4, 2011 I looked into this a while ago and found it very annoying. I then reverted to the method I currently use on my site. Simply store the image in a directory on your server, if you are uploading the function you would use would be move_uploaded_file(), then you can get the images in one array from a whole directory using the glob() function with *.jpg Look up a file upload tutorial on google, they are everywhere and most will use this method. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 Slightly off-topic, but your prepare(), bind_param(), and close() statements should not be inside the foreach() loop. The foreach loop should be inside of the if($query = $db->connection->prepare("...."){ ... } statement. After you successfully prepare and bind the variables, you should loop over the data. The only thing that should be inside the foreach loop is the $query->execute(); statement and any error checking logic to test if the query had an error or not and if it inserted the row or not. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 Also, your $db instance is not directly an instance of the mysqli class and could have something to do with the problem. Please post your db class. As already stated, you need to provide enough of your code that duplicates the problem. And as I have had to write in other threads, if the code you post isn't everything that someone would need to duplicate the problem, don't bother posting it, it is just a waste of your and our time. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 I believe you should be using send_long_data() for this operation. ^^^ Doing this will get your image data to be inserted into the table (just tested.) From the documentation for that function - Allows to send parameter data to the server in pieces (or chunks), e.g. if the size of a blob exceeds the size of max_allowed_packet. It should read - You must use this function to send 'b' type (blob) data in a prepared statement, regardless of the size. If the total size of all the data in one query exceeds the size of max_allowed_packet setting, you can call this function multiple times to send the parameter data to the server in pieces (or chunks.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.