Page 1 of 1

Files get corrupted in uploads

Posted: Mon Jun 16, 2003 6:55 pm
by emac
Mac Os 10.1.5, PHP 4.1.2, Apache1.2.22

Even with the simpliest code, (in fact copy/pasting example from PHP Manual !) uploading locally, I get files corrupted.
I upload a Word file then I´ll can´t open with Word the uploaded file.

I tried with move_uploade_file() and copy() also.

I treid also with strictly unix files - made with BBedit or with Mac Os TextEdit (guessin it was a matter of resourse/fork Mac issue) -; same problem.

Does anybody know what´s going on?

Thanks in advance.

Edwin.

Posted: Tue Jun 17, 2003 8:33 am
by glenn
Can you past the code you are using and I will see what I can do!

Uploading files to a server can always be hard! I do have a script that uploads files that I made sometime ago and will look over it for you!!!

But I would still like to see your coding...

Glenn.

Posted: Tue Jun 17, 2003 10:54 am
by emac
First I write a code full of validation and didn´t work.

Then use the simplies one borrow from the manual:

Code: Select all

<?php

$uploaddir = '/Users/edwin/Sites/Congreso03/resumenes/';
// >>>>field name used in form is "resumen"<<<
print "<pre>";
if (move_uploaded_file($_FILES&#1111;'resumen']&#1111;'tmp_name'], $uploaddir . $_FILES&#1111;'resumen']&#1111;'name'])) &#123;

	//if (copy($_FILES&#1111;'resumen']&#1111;'tmp_name'], $uploaddir . 
$_FILES&#1111;'resumen']&#1111;'name'])) &#123;  <<< I tried this way to cause read in a forum 
   
 print "File is valid, and was successfully uploaded.  Here's some more debugging info:\n";
    print_r($_FILES);
&#125; else &#123;
    print "Possible file upload attack!  Here's some debugging info:\n";
    print_r($_FILES);
&#125;

?>
As you see coudn´t be a problem in the code as it´s so simply.
I think the problem is in the configuration of my server, I´m afraid.

Could be a configuration in php.ini? Don´t think so. In the Apache: may be.

Now I, m trying to test that simple code in a Linux server just to confirm muy suposition.

Thanks.

PD: Excuse my english.

Posted: Tue Jun 17, 2003 12:50 pm
by Galahad
Have you tried uploading a simple text file? That may be a good place to start.

Posted: Tue Jun 17, 2003 4:09 pm
by emac
Quite Odd!!!

I was tried early with a TextEdit file and with a pdf one: both get corrupted.

When you suggest wit Simple Text I tried with a php log file and it wasn´t corrupted!!
Then I did with a pdf again and now it works fine ?¿?¿?

So I get the originaly file to upload, a Word template: corrupt. (Congreso2003.doc)
Resave and Try: corrupt.
Save with another name (Congreso.doc): Not corruted!!!!!

:?

Edwin