RE: [PHP] Images being uploaded in ASCII format
| From: | Pablo Gosse | Date: | Thu, 23 Oct 2003 17:22:45 +0000 |
| Subject: | RE: [PHP] Images being uploaded in ASCII format | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-167324@lists.php.net to get a copy of this message | ||
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:jabber@raditha.com]
Sent: Thursday, October 23, 2003 10:19 AM
Cc: php-general@lists.php.net
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>
><title>File 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