<html>
<head>
<title>Junk - Test File</title>
<link href="/css/popup.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var Base64 = {
enc_lookup : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode : function (input) {
var output = "";
var i = 0;
while (i < input.length) {
output = output + Base64.encode_57b(input.substr(i,57)) + "\n";
i += 57;
}
return output;
},
encode_57b : function (line_b57) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
while (i < line_b57.length) {
chr1 = line_b57.charCodeAt(i++);
chr2 = line_b57.charCodeAt(i++);
chr3 = line_b57.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this.enc_lookup.charAt(enc1) + this.enc_lookup.charAt(enc2) +
this.enc_lookup.charAt(enc3) + this.enc_lookup.charAt(enc4);
}
return output;
}
}
function put_bin_file($Part,$FileName,$FileSize,$FileContents){
var xmlhttp;
var resource = "http://foobar.com.au/cgi-bin/put_post.pl";
var contents = $FileContents;
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",resource,false);
xmlhttp.setRequestHeader("FILEPUT_USER","FOO")
xmlhttp.setRequestHeader("FILEPUT_SSID","9999")
xmlhttp.setRequestHeader("FILEPUT_NAME",$FileName)
xmlhttp.setRequestHeader("FILEPUT_SIZE",$FileSize)
xmlhttp.setRequestHeader("FILEPUT_PART",$Part)
xmlhttp.send(Base64.encode(contents));
}
</script>
</head>
<body>
<div>
<hr>
<h2>Test HTML PUT method</h2>
<input type="file" id="fileinput" />
<script type="text/javascript">
function readSingleFile(evt) {
var File = evt.target.files[0];
var part_size = 1048576;
if (File) {
if ( File.size < part_size + 1) {
var FileIn = new FileReader();
FileIn.onload = function(evt) {
var contents = evt.target.result;
put_bin_file(0,File.name,File.size,contents);
}
FileIn.readAsBinaryString(File);
} else {
var FileIn = new FileReader();
FileIn.onload = function(evt) {
var contents = evt.target.result;
var n = 1
var begin = 0;
while (begin <= File.size) {
put_bin_file(n++,File.name,File.size,contents.substr(begin,part_size));
begin += part_size;
}
}
FileIn.readAsBinaryString(File);
}
} else {
alert("Failed to load file");
}
}
document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
</script>
<div>
</div>
</body>
</html>