I have a site that is running php 4 on a linux machine. My browser is ie6, and I'm using windows xp. I have a simple upload script (see below). When it is used the file uploads to the correct spot, with the correct permissions. However the file is corrupted. When I view it as a text file certain bits are replaced with spaces at random intervals. I've tried multiply upload scripts from discussion boards all over the web. Is there a php 4 problem? Is there something about going from xp to linux? I've been going crazy. I even tried using fopen and copying that way. Still the corruption happens. Please take a look at this code and tell me why I'm an idiot. I must be doing something really stupid.
form:
<form action="../scripts/updatePictures.php?postId=<?php print("$postId"); ?>&topicId=<?php print("$topicId"); ?>§ionId=<?php print("$sectionId"); ?>" enctype="multipart/form-data" method=POST>
Picture To Upload:<br>
<input type="file" name="fileupload"><br>
Caption:<br>
<input name="caption" type="text" size="40" maxlength="250">
<br>
Title:<br>
<input name="title" type="text" size="40" maxlength="250">
<br>
Description:<br>
<textarea name="description" cols="40" rows="5"></textarea>
<br><br>
<input name="submit" type=submit value="SUBMIT">
</form>
upload code from updatePicture.php:
$fileName=$FILES['fileupload']['name'];
$fileDir="../images/pagepics/$postId";
if(!is_dir("$fileDir"))
{
mkdir("$fileDir",0777);
}
if(is_uploaded_file($FILES['fileupload']['tmp_na
me']))
{
move_uploaded_file($_FILES['fileupload']['tmp_na
me'],"$fileDir/$fileName") or die("Couldn't Copy");
}
if(!chmod("$fileDir/$fileName", 0747)) {
print("Error Changing Permissions, This File May Not Be Able To Be Viewed");
}
**note: I've tried using copy instead of move_uploaded_file, I've tried fopen, I've tried multiple variations of this code above.