I'm having trouble with making a php uploading script. I have it set up so that a file will be sent to a directory and copied there. The copy works fine, the move from the temp directory works fine, the renaming works fine...
but it replaces all the (") and (') symbols with (\") or (\') respectively. I realize it must be trying to make it so that php can read it (you DO want it to say that... if it's running in php!)
The problem is, it does this automatically for all the symbols of the type in the file. This makes text files very hard to read, and it corrupts image files.
Here's the code I typed: (the copy part I got from another site, but I've already forgotten the authors name.)
<?php
if ($userfile_type == "image/gif" || $userfile_type == "image/pjpeg" || $userfile_type == "text/plain") {
echo "$userfile <BR>$userfile_name <BR>$userfile_size <BR>$userfile_type";
$UPLOAD = fopen( $userfile, "r" );
$contents = fread( $UPLOAD,$userfile_size);
eregi_replace ('\"','"', $contents);
fclose( $UPLOAD );
$SAVEFILE = fopen("upload/".$userfile_name, "wb" );
fwrite( $SAVEFILE, $contents,$userfile_size);
fclose( $SAVEFILE );
}
else {
echo "You did not upload a .gif or .jpg ot .txt file! the file type '$userfile_type' is not allowed! please select an image!";
}
?>