I am trying to provide a file upload form to the user with the standard inputType as 'file'.

The goal is to let the user see the uploaded contents back in a TextArea so that he can further edit the content.

I have written a PHP that does the below:

Code:
<?php

    if (is_uploaded_file($_FILES['tpFile']['tmp_name']))
        $fileData = file_get_contents($_FILES['tpFile']['tmp_name']);
    echo '{success:true, file:\''. $fileData . '\'}';;
?>
The client side submits and receives like the below:

Code:
                
                   if(fp.getForm().isValid()){
                    fp.getForm().submit({
                        url: '/echoupload.php',
                        waitMsg: 'Uploading your data file...',
                        success: function(fp, o){
                            theTextArea.setRawValue(o.result.file);
                            
                        },failure: function(fp, o){
                            theTextArea.setRawValue(o.result.file);
                            
                        }
                    });
There are two problems:

1. This is not working in FireFox (FireBug shows an empty string for o.result.file.

2. It is working in IE but the new lines are stripped off and all content is displayed in one line.

Is there a standard approach to do this that I am over-engineering? The uploaded file can have data including special characters, new lines etc.