RE: [PHP] Images being uploaded in ASCII format
Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag Thanks for the tip, but that's not the problem. My code is below, and as you can see there is nothing in the code that would be causing this. It has to be something in the server, and while there have been a few posts to these lists about this problem, never a resolution for the problem. Here's the code: ?php function handleupload() { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $realname = $_FILES['userfile']['name']; if(copy($_FILES['userfile']['tmp_name'], '/path/to/file/'.$realname)) { echo 'br /'.$realname.' uploaded/font'; } else { echo 'br /'.$realname.'could not be uploaded/font'; } } else { echo 'br /Possible file upload attack: filename '.$_FILES['userfile']['name'].'.'; } } ? html head titleFile Upload/title /head body ?php if (isset($_POST['method']) $_POST['method'] == 'upload') handleupload(); ? form ENCTYPE=multipart/form-data method=POST action=?php echo $_SERVER['PHP_SELF']; ? input type=hidden name=method value=upload File:input type=file name=userfile size=35 input type=submit value=upload name=submit /form /body /html This is very standard code, yet the images are uploaded in ascii format. Does anyone have any idea why this is happening? How can I for the http uploads to auto-detect? I've looked through the entire php.ini and httpd.conf files and I can't seem to find anything, and as I mentioned above none of the previous posts on this topic have been resolved. Anyone? Thanks much in advance, Pablo Thursday, October 23, 2003, 4:05:13 AM, you wrote: PG Hi all. I'd like to take a brief sentence to introduce myself first. PG My name is Pablo Gosse, and I've just recently joined the php-general PG list. I've been using PHP since early 2000, and work as webmaster PG at the University of Northern British Columbia. PG I'm running into a problem with file uploads being handled in ascii PG rather than binary format. PG I've been writing a CMS for the past few months and the wysiwyg editor PG we're integrating has a very nice image manager built in PG (www.devedit.com). However, the uploads are being transferred in ascii PG format instead of binary (or auto-detect) which is mangling all the PG images. PG I've done a lot of research into this but can't seem to pin down the PG problem. I've looked through both my php.ini and httpd.conf and can't PG seem to find anything there that would remedy this problem. PG Does anyone have any advice as to where I should be looking to fix this PG problem? PG Thanks much in advance. PG Cheers, PG Pablo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images being uploaded in ASCII format
Hi Pablo, Could you explain what exactly you mean by transferred in ASCII mode? do you find that cr/lf combinations are translated (there by corrupting your image) or some other corruption takes place? Have you opened the files with a hex editor to see the contents? I am sorry if you have mentioned these before, i don't have the older messages in this thread. Pablo Gosse wrote: Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag Thanks for the tip, but that's not the problem. My code is below, and as you can see there is nothing in the code that would be causing this. It has to be something in the server, and while there have been a few posts to these lists about this problem, never a resolution for the problem. Here's the code: ?php function handleupload() { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $realname = $_FILES['userfile']['name']; if(copy($_FILES['userfile']['tmp_name'], '/path/to/file/'.$realname)) { echo 'br /'.$realname.' uploaded/font'; } else { echo 'br /'.$realname.'could not be uploaded/font'; } } else { echo 'br /Possible file upload attack: filename '.$_FILES['userfile']['name'].'.'; } } ? html head titleFile Upload/title /head body ?php if (isset($_POST['method']) $_POST['method'] == 'upload') handleupload(); ? form ENCTYPE=multipart/form-data method=POST action=?php echo $_SERVER['PHP_SELF']; ? input type=hidden name=method value=upload File:input type=file name=userfile size=35 input type=submit value=upload name=submit /form /body /html This is very standard code, yet the images are uploaded in ascii format. Does anyone have any idea why this is happening? How can I for the http uploads to auto-detect? I've looked through the entire php.ini and httpd.conf files and I can't seem to find anything, and as I mentioned above none of the previous posts on this topic have been resolved. Anyone? Thanks much in advance, Pablo Thursday, October 23, 2003, 4:05:13 AM, you wrote: PG Hi all. I'd like to take a brief sentence to introduce myself first. PG My name is Pablo Gosse, and I've just recently joined the php-general PG list. I've been using PHP since early 2000, and work as webmaster PG at the University of Northern British Columbia. PG I'm running into a problem with file uploads being handled in ascii PG rather than binary format. PG I've been writing a CMS for the past few months and the wysiwyg editor PG we're integrating has a very nice image manager built in PG (www.devedit.com). However, the uploads are being transferred in ascii PG format instead of binary (or auto-detect) which is mangling all the PG images. PG I've done a lot of research into this but can't seem to pin down the PG problem. I've looked through both my php.ini and httpd.conf and can't PG seem to find anything there that would remedy this problem. PG Does anyone have any advice as to where I should be looking to fix this PG problem? PG Thanks much in advance. PG Cheers, PG Pablo -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Images being uploaded in ASCII format
Hi Raditha. Thanks very much for your reply. I've not been having much luck with this one. This is how the images should appear: http://web.unbc.ca/~gossep/sample_images/1.gif http://web.unbc.ca/~gossep/sample_images/nav-02.jpg And here is how they appear after being uploaded: http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg The results to me seem the same as if an image were FTPed in ascii mode instead of binary mode (or auto-detect which would ultimately set the mode to binary). I just downloaded the XVI32 hex editor, but what should I be looking for when I open the files and examine the contents? Some other particulars to this situation: I've tried uploading the same images through the demo site on the company from which we purchased our editor (www.devedit.com) and they upload fine, making me certain it's a system setting on my system causing the problem. My system is as follows: Dell Precision 340 Workstation RedHat 9.0 Apache 2.0 PHP 4.2.2 Thanks with your help, Raditha. Greatly appreciated. Cheers, Pablo -Original Message- From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 10:19 AM Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Images being uploaded in ASCII format Hi Pablo, Could you explain what exactly you mean by transferred in ASCII mode? do you find that cr/lf combinations are translated (there by corrupting your image) or some other corruption takes place? Have you opened the files with a hex editor to see the contents? I am sorry if you have mentioned these before, i don't have the older messages in this thread. Pablo Gosse wrote: Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag Thanks for the tip, but that's not the problem. My code is below, and as you can see there is nothing in the code that would be causing this. It has to be something in the server, and while there have been a few posts to these lists about this problem, never a resolution for the problem. Here's the code: ?php function handleupload() { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $realname = $_FILES['userfile']['name']; if(copy($_FILES['userfile']['tmp_name'], '/path/to/file/'.$realname)) { echo 'br /'.$realname.' uploaded/font'; } else { echo 'br /'.$realname.'could not be uploaded/font'; } } else { echo 'br /Possible file upload attack: filename '.$_FILES['userfile']['name'].'.'; } } ? html head titleFile Upload/title /head body ?php if (isset($_POST['method']) $_POST['method'] == 'upload') handleupload(); ? form ENCTYPE=multipart/form-data method=POST action=?php echo $_SERVER['PHP_SELF']; ? input type=hidden name=method value=upload File:input type=file name=userfile size=35 input type=submit value=upload name=submit /form /body /html This is very standard code, yet the images are uploaded in ascii format. Does anyone have any idea why this is happening? How can I for the http uploads to auto-detect? I've looked through the entire php.ini and httpd.conf files and I can't seem to find anything, and as I mentioned above none of the previous posts on this topic have been resolved. Anyone? Thanks much in advance, Pablo Thursday, October 23, 2003, 4:05:13 AM, you wrote: PG Hi all. I'd like to take a brief sentence to introduce myself first. PG My name is Pablo Gosse, and I've just recently joined the php-general PG list. I've been using PHP since early 2000, and work as webmaster PG at the University of Northern British Columbia. PG I'm running into a problem with file uploads being handled in ascii PG rather than binary format. PG I've been writing a CMS for the past few months and the wysiwyg editor PG we're integrating has a very nice image manager built in PG (www.devedit.com). However, the uploads are being transferred in ascii PG format instead of binary (or auto-detect) which is mangling all the PG images. PG I've done a lot of research into this but can't seem to pin down the PG problem. I've looked through both my php.ini and httpd.conf and can't PG seem to find anything there that would remedy this problem. PG Does anyone have any advice as to where I should be looking to fix this PG problem? PG Thanks much in advance. PG Cheers, PG Pablo -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe
Re: [PHP] Images being uploaded in ASCII format
Hi Pablo Pablo Gosse wrote: Hi Raditha. Thanks very much for your reply. I've not been having much luck with this one. welcome This is how the images should appear: http://web.unbc.ca/~gossep/sample_images/1.gif http://web.unbc.ca/~gossep/sample_images/nav-02.jpg And here is how they appear after being uploaded: http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg 1.gif and 1_uploaded.gif differ by much as 4Kb in length! and the first difference occurs at byte number 1276. (I used cmp) The results to me seem the same as if an image were FTPed in ascii mode instead of binary mode (or auto-detect which would ultimately set the mode to binary). Though the output might look like that it's misleading because you are using HTTP post. Unfortunately PHP does not allow access to raw POST data, else this can be debugged by looking at that data. I will mail you (offlist) a small perl script that you can use to write out the POST to a temp file and may be help you get to the bottom of this. I just downloaded the XVI32 hex editor, but what should I be looking for when I open the files and examine the contents? Khexedit might be installed by default. all the best -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Images being uploaded in ASCII format
Something wrong is with your uploader program... look at this: Content-Disposition: form-data; name=upload; filename=C:\Documents and Settin gs\gossep\Desktop\ewimages\1.gif And if you look closer to the data in the file, you will see it has 2 GIF or something (GIF8 twice)... so yep, you have something really wrong with your uploader. El jue, 23-10-2003 a las 13:22, Pablo Gosse escribió: Hi Raditha. Thanks very much for your reply. I've not been having much luck with this one. This is how the images should appear: http://web.unbc.ca/~gossep/sample_images/1.gif http://web.unbc.ca/~gossep/sample_images/nav-02.jpg And here is how they appear after being uploaded: http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg The results to me seem the same as if an image were FTPed in ascii mode instead of binary mode (or auto-detect which would ultimately set the mode to binary). I just downloaded the XVI32 hex editor, but what should I be looking for when I open the files and examine the contents? Some other particulars to this situation: I've tried uploading the same images through the demo site on the company from which we purchased our editor (www.devedit.com) and they upload fine, making me certain it's a system setting on my system causing the problem. My system is as follows: Dell Precision 340 Workstation RedHat 9.0 Apache 2.0 PHP 4.2.2 Thanks with your help, Raditha. Greatly appreciated. Cheers, Pablo -Original Message- From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 10:19 AM Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Images being uploaded in ASCII format Hi Pablo, Could you explain what exactly you mean by transferred in ASCII mode? do you find that cr/lf combinations are translated (there by corrupting your image) or some other corruption takes place? Have you opened the files with a hex editor to see the contents? I am sorry if you have mentioned these before, i don't have the older messages in this thread. Pablo Gosse wrote: Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag Thanks for the tip, but that's not the problem. My code is below, and as you can see there is nothing in the code that would be causing this. It has to be something in the server, and while there have been a few posts to these lists about this problem, never a resolution for the problem. Here's the code: ?php function handleupload() { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $realname = $_FILES['userfile']['name']; if(copy($_FILES['userfile']['tmp_name'], '/path/to/file/'.$realname)) { echo 'br /'.$realname.' uploaded/font'; } else { echo 'br /'.$realname.'could not be uploaded/font'; } } else { echo 'br /Possible file upload attack: filename '.$_FILES['userfile']['name'].'.'; } } ? html head titleFile Upload/title /head body ?php if (isset($_POST['method']) $_POST['method'] == 'upload') handleupload(); ? form ENCTYPE=multipart/form-data method=POST action=?php echo $_SERVER['PHP_SELF']; ? input type=hidden name=method value=upload File:input type=file name=userfile size=35 input type=submit value=upload name=submit /form /body /html This is very standard code, yet the images are uploaded in ascii format. Does anyone have any idea why this is happening? How can I for the http uploads to auto-detect? I've looked through the entire php.ini and httpd.conf files and I can't seem to find anything, and as I mentioned above none of the previous posts on this topic have been resolved. Anyone? Thanks much in advance, Pablo Thursday, October 23, 2003, 4:05:13 AM, you wrote: PG Hi all. I'd like to take a brief sentence to introduce myself first. PG My name is Pablo Gosse, and I've just recently joined the php-general PG list. I've been using PHP since early 2000, and work as webmaster PG at the University of Northern British Columbia. PG I'm running into a problem with file uploads being handled in ascii PG rather than binary format. PG I've been writing a CMS for the past few months and the wysiwyg editor PG we're integrating has a very nice image manager built in PG (www.devedit.com). However, the uploads are being transferred in ascii PG format instead of binary (or auto-detect) which is mangling all the PG images. PG I've done a lot of research into this but can't seem to pin down the PG problem. I've looked through both my php.ini and httpd.conf and can't PG seem to find anything there that would remedy this problem. PG Does anyone have any advice as to where I should be looking to fix this PG problem? PG
RE: [PHP] Images being uploaded in ASCII format
Thanks Raditha. At least now I know I've been looking in the wrong place! I'll look forward to the perl script to see if it sheds any more light on this situation. I'm currently running Windoze, but when I boot to Linux later I'll try Khexedit to see what I can come up with. Cheers, Pablo -Original Message- From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 10:48 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Images being uploaded in ASCII format Hi Pablo Pablo Gosse wrote: Hi Raditha. Thanks very much for your reply. I've not been having much luck with this one. welcome This is how the images should appear: http://web.unbc.ca/~gossep/sample_images/1.gif http://web.unbc.ca/~gossep/sample_images/nav-02.jpg And here is how they appear after being uploaded: http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg 1.gif and 1_uploaded.gif differ by much as 4Kb in length! and the first difference occurs at byte number 1276. (I used cmp) The results to me seem the same as if an image were FTPed in ascii mode instead of binary mode (or auto-detect which would ultimately set the mode to binary). Though the output might look like that it's misleading because you are using HTTP post. Unfortunately PHP does not allow access to raw POST data, else this can be debugged by looking at that data. I will mail you (offlist) a small perl script that you can use to write out the POST to a temp file and may be help you get to the bottom of this. I just downloaded the XVI32 hex editor, but what should I be looking for when I open the files and examine the contents? Khexedit might be installed by default. all the best -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Images being uploaded in ASCII format
Hi, Friday, October 24, 2003, 2:11:43 AM, you wrote: PG Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag PG Thanks for the tip, but that's not the problem. My code is below, and PG as you can see there is nothing in the code that would be causing this. PG It has to be something in the server, and while there have been a few PG posts to these lists about this problem, never a resolution for the PG problem. What operating system is the server running on? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Images being uploaded in ASCII format
Hi, Friday, October 24, 2003, 2:11:43 AM, you wrote: PG Hi Tom. make sure you have ENCTYPE=multipart/form-data in the form tag PG Thanks for the tip, but that's not the problem. My code is below, and PG as you can see there is nothing in the code that would be causing this. PG It has to be something in the server, and while there have been a few PG posts to these lists about this problem, never a resolution for the PG problem. PG Here's the code: Another thing is to try move_uploaded_file() instead of copy, if your server is on windows copy maybe doing strange things as copy needs /b to indicate binary, just a guess. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images being uploaded in ASCII format
Pablo Gosse wrote: Hi Raditha. Thanks very much for your reply. I've not been having much luck with this one. This is how the images should appear: http://web.unbc.ca/~gossep/sample_images/1.gif http://web.unbc.ca/~gossep/sample_images/nav-02.jpg And here is how they appear after being uploaded: http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg The results to me seem the same as if an image were FTPed in ascii mode instead of binary mode (or auto-detect which would ultimately set the mode to binary). Use strings to look at the files. This: yPZ-7d33511600b6 Content-Disposition: form-data; name=upload; filename=C:\Documents and Settings\gossep\Desktop\ewimages\1.gif Content-Type: image/gif GIF89a certainly doesn't belong in the image. Apache 2.0 PHP 4.2.2 PHP 4.2.2 is 300 years old - I'm surprised that Apache 2 existed back then. See http://www.php.net/manual/en/install.apache2.php. Regards... Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Images being uploaded in ASCII format
Hi all. I'd like to take a brief sentence to introduce myself first. My name is Pablo Gosse, and I've just recently joined the php-general list. I've been using PHP since early 2000, and work as webmaster at the University of Northern British Columbia. I'm running into a problem with file uploads being handled in ascii rather than binary format. I've been writing a CMS for the past few months and the wysiwyg editor we're integrating has a very nice image manager built in (www.devedit.com). However, the uploads are being transferred in ascii format instead of binary (or auto-detect) which is mangling all the images. I've done a lot of research into this but can't seem to pin down the problem. I've looked through both my php.ini and httpd.conf and can't seem to find anything there that would remedy this problem. Does anyone have any advice as to where I should be looking to fix this problem? Thanks much in advance. Cheers, Pablo --- Pablo Gosse Webmaster University of Northern British Columbia 250.960.5621 [EMAIL PROTECTED] --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images being uploaded in ASCII format
Hi, Thursday, October 23, 2003, 4:05:13 AM, you wrote: PG Hi all. I'd like to take a brief sentence to introduce myself first. PG My name is Pablo Gosse, and I've just recently joined the php-general PG list. I've been using PHP since early 2000, and work as webmaster PG at the University of Northern British Columbia. PG I'm running into a problem with file uploads being handled in ascii PG rather than binary format. PG I've been writing a CMS for the past few months and the wysiwyg editor PG we're integrating has a very nice image manager built in PG (www.devedit.com). However, the uploads are being transferred in ascii PG format instead of binary (or auto-detect) which is mangling all the PG images. PG I've done a lot of research into this but can't seem to pin down the PG problem. I've looked through both my php.ini and httpd.conf and can't PG seem to find anything there that would remedy this problem. PG Does anyone have any advice as to where I should be looking to fix this PG problem? PG Thanks much in advance. PG Cheers, PG Pablo make sure you have ENCTYPE=multipart/form-data in the form tag -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php