0

我被困住了。我正在使用不允许直接上传的服务器。我希望能够使用 HTML5 读取文件,如果它是文本而不是图像则可以正常工作:

 reader.onloadend = function(evt) {
  if (evt.target.readyState == FileReader.DONE) { // DONE == 2
    document.getElementById('data').textContent = evt.target.result;
            console.log(evt.target.result);
    //document.getElementById('byte_range').textContent = 
      //  ['Read bytes: ', start + 1, ' - ', stop + 1,
     //    ' of ', file.size, ' byte file'].join('');
            updatePage();
  }
};              

if (file.type.match("text*") || (file.type.match() == '')){
    //var blob = file.slice(start, stop + 1);
    reader.readAsBinaryString(file);

    }else{
        reader.readAsDataURL(file);

    }

在用经典asp编写的下一页上无法读取数据:

Dim strSourceFile, strFolder
Dim strFileName, fsc, fname, c,f,d

c= Request.Form("c")
f= Request.Form("f")
d= Response.BinaryWrite(Request.Form("d")) 


f= Server.mappath("\uploads") & "\" & f

'works for text files   
set fsC=Server.CreateObject("Scripting.FileSystemObject")
set fname=fsC.CreateTextFile(f,true)
fname.Write(d)
fname.Close
set fname=nothing
set fsC=nothing

Response.ContentType = "image/JPEG" 

'isn't working for either
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
dim bStream : set bStream = server.CreateObject("ADODB.stream")
bStream.type = adTypeBinary
call bStream.Open()
call bStream.Write(d)
call bStream.SaveToFile(strSourceFile, adSaveCreateOverWrite)
call bStream.close()
set bStream = nothing
4

0 回答 0