jasonhardwick Posted May 25, 2008 Share Posted May 25, 2008 Ok I've had this problem for a while now and no one seems to know how to help... so i'm trying again... i need this function to resize, rename and upload an image but for some reaseon I cant get it to work can anyone help? Thank, j <?php include "config.php"; $user_image = $_FILES['user_image']['tmp_name']; $filename1 = $_FILES['user_image']['name']; function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $src1 = imagecreatefromjpeg($user_image); list($width,$height)=getimagesize($user_image); $newwidth1=250; $newheight1=($height/$width)*250; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src1,0,0,0,0,$newwidth1,$newheight1,$width,$height); $tbl_name="user"; $username=$_SESSION['username']; $resault = explode($_FILES[$filename1]['name'], '.'); $ext = findexts ($_FILES['user_image']['name']) ; $new_name = $username."."; imagejpeg($tmp1,$target,100); $target = "user_images/"; $target1 = $target . $new_name.$ext; if(move_uploaded_file($_FILES['user_image']['tmp_name'], $target1)) { $sql=( "UPDATE $tbl_name SET user_image = '".$new_name.$ext."' WHERE uname='$username'"); echo "Your profile image has been sucessfully updated"; $id = mysql_insert_id(); } else { echo "Sorry, there was a problem uploading your file."; } imagedestroy($src1); imagedestroy($tmp1); ?> Quote Link to comment Share on other sites More sharing options...
me1000 Posted May 25, 2008 Share Posted May 25, 2008 You are going about it in the wrong order... (without looking at any of your code) you need to upload the image before you do anything to it. Then you can resize and rename it on the server. Quote Link to comment Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 ok... can someone look at the code... Quote Link to comment Share on other sites More sharing options...
trq Posted May 27, 2008 Share Posted May 27, 2008 ok... can someone look at the code... Can someone describe there problem? Quote Link to comment Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 yeah, sorry i'll go into more detail... ok I would like to let my users upload an image. I want to resize it to save space on the server and also rename it to the users USERNAME but for some reason I get this as my output ... but nothing happens, no image is uploaded. Warning: explode(): Empty delimiter. in /home/content/j/a/s/jasonhardwick/html/update_profile_image.php on line 124 ����JFIF�����n�Wϵ��P��B�z�q� y��#O��q�%����[vםX�I����dr{� u�⬣Z��ZI$��*<�[�ӌ� �w��h{�3k���{:~�^�Zp��NU8����ղ��̣�.^mNn�DsH����� і��W�w$�jƙ O���:�{�!�T�%%���� �=��j���� #�#�w��`�����8�4���F��2�9���N�mn�.�Ҷ�N ]S������Z}u��}���Ƴ����U��Y~̐ �<�҃V�Qu�S���zY/��~-b�ڊ�% `j��ޝLJϕj��J���q�n��zLzG����ۛ�+�z��Wj������@�� �7e�w�x<��a߆��h�5� n�4i%Yc� �6��/mݢ�V�l<������&�����Ф�kr.l��b�ѵ�ƿ�:0���٬D�S�N5c ����T�^�*���`r�6!�'*-�Ҧ��U��R��R�Hh�̿�χ�Yx?�Zu��m&�l�m�c��L��f��;Yi ���G#�(��qn�w�����_�m�jW�_�~\_xO�V]�x�\�c�6��N妺�5Hm�����d(I$���'���e��&��U���.�HԜ�����#+6����~���*8�1����T�gȝ8�A����Sko�>9�Ҿ�[��Ƌ����^��b��k���.I>ĞI�kb�5�SAmm��Q���~6x�㧋�ĺ���D���(�����D���&\��6Fl�IExN�>lD`���c6�qN1o��;��vޛ����MI`jW����n�\�NrZ��7q|�&�I]'m�L�C�����OA�I�d����\� ��n��4pƃ��HꑯX�ӂW�Ȣ��`����$���i1'� 5�bڿt��岱�^~����S�s���T�����3_\D�z�́@$��O,��FeU ��7��V��/� �])'{�#��|5���JY�b�_�k��F����g�p!4�pJĪ +�s�&�X��ߺ¾(�pNm7��'*T[OZq�*R�j����\��|�HG[9�W^�α���bq<��k��$�Տ5�I����6�,�d�7��l���e+��f `�eJ� �q�i/�7�:��K#�֭&��=˼�4= ��g$�7w6ח�C�[��bJ+��^�Q��75����b�S�����E���U]-k��nTv�i��[5�b*S�����p?<�긪�x�M�u�i�N /�<�����e��fr���QB(�>P2@=U=�3�d�r029�W��rM�qo��o]����Z1I$�$���lC���ٹ���<k�����7B�80�]Ԃ�`����\t�8���EEf�M�=y/}�IY��[�N�*�R�惕�~��M�Vgqa{�:9�/�f���Y�:���r�9g ��k�%�B�ᕐ��03�� �d��օY�m^�K[�K]�u��q��%������4������ӱ���M#�8E�7�� �We��dr�8 $X�X���99r΅�v+���R����QX�M�u�~���GL)�����ӳm�nկk�yw?��Your profile image has been sucessfully updated Quote Link to comment Share on other sites More sharing options...
Pioden Posted May 27, 2008 Share Posted May 27, 2008 Try using this ... imagemagick_class. It has some example code too which helps :-) http://www.bokko.nl/wp-content/plugins/DownloadCounter/download.php?id=2 It can, with a few modifications, do everything you require. Huw 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.