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