Files get corrupted in uploads

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emac
Forum Newbie
Posts: 3
Joined: Mon Jun 16, 2003 6:55 pm
Location: Buenos Aires, Argentina.
Contact:

Files get corrupted in uploads

Post 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.
glenn
Forum Newbie
Posts: 18
Joined: Fri Apr 19, 2002 7:42 am
Location: London, England (UK)

Post 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.
emac
Forum Newbie
Posts: 3
Joined: Mon Jun 16, 2003 6:55 pm
Location: Buenos Aires, Argentina.
Contact:

Post 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.
Galahad
Forum Contributor
Posts: 111
Joined: Fri Jun 14, 2002 5:50 pm

Post by Galahad »

Have you tried uploading a simple text file? That may be a good place to start.
emac
Forum Newbie
Posts: 3
Joined: Mon Jun 16, 2003 6:55 pm
Location: Buenos Aires, Argentina.
Contact:

Post 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
Post Reply