Javascript 文件内容

Javascript File Contents

所以我得到了这个脚本,它应该以 base64 编码输出上传文件的文件内容,问题是它还输出类似 data:image/jpeg;base64 的内容,在开头编码输出。我需要做什么才能让这个脚本只输出上传文件的编码文件内容而不是数据:image/jpeg;base64 等?

    <html>
<head>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
</head>
<body>
    <script>
        function PreviewImage() {
        var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
        oFReader.onload = function (oFREvent) {
            var sizef = document.getElementById('uploadImage').files[0].size;
            document.getElementById("uploadPreview").src = oFREvent.target.result;
            document.getElementById("uploadImageValue").value = oFREvent.target.result; 
        };
    };
    jQuery(document).ready(function(){
        $('#viewSource').click(function ()
        {
            var imgUrl = $('#uploadImageValue').val();
            document.write(imgUrl);

        });
    });
    </script>
    <div>
        <input type="hidden" id="uploadImageValue" name="uploadImageValue" value="" />
        <img id="uploadPreview" style="width: 150px; height: 150px;" /><br />
        <input id="uploadImage" style="width:120px" type="file" size="10" name="myPhoto" onchange="PreviewImage();" />
    </div>
    <a href="#" id="viewSource">Source file</a>
</body>

将代码更改为

document.write(imgUrl.split(',').pop());
                     ^^^^^^^^^^^^^^^^^

var imgUrl = $('#uploadImageValue').val().split(',').pop();                     
                                         ^^^^^^^^^^^^^^^^^