我正在尝试从nativescript js移动应用上传图片。
在尝试上载之前,我正在应用程序中显示图像时,该应用程序正在获取图像。
这是手机代码
var filename = appSettings.getString("filename");
var session = bghttp.session("image-upload");
var options = {
url: "https://webservice_url/service.asmx/SaveFiles",
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name": loginId+".jpg"
},
description: "{'Uploading': 'Uploading File....'}"
}
let task = session.uploadFile("file://"+imgPath,options);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e){
console.log(e.eventName);
}
这是asp.net代码
Public Function SaveFiles() As String
Dim newfileparam() As String
'Dim newpathparam() As String
'Dim Rotation() As String
' Try
'writefile("Function called")
Dim FileCount As Integer = 0
FileCount = HttpContext.Current.Request.Files.Count
writefile("FileCount = " + FileCount.ToString)
For i As Integer = 0 To FileCount - 1
myfile = HttpContext.Current.Request.Files(i)
FileName = HttpContext.Current.Request.Files(i).FileName
writefile("FileName = " + FileName)
If FileName.EndsWith(".jpg") Then
FileName += ".jpg"
End If
If FileName.EndsWith(".mov") Then
FileName += ".mov"
End If
If FileName.EndsWith(".mp4") Then
FileName += ".mp4"
End If
Dim parameters As NameValueCollection = HttpContext.Current.Request.Params
newfileparam = parameters.GetValues("newfile")
writefile("newfileparam length: " + newfileparam.Length.ToString)
newfilename += newfileparam(0).ToString
Next
writefile("Newfilename=" + newfilename)
newfileloc = Path.Combine("d:\images", newfilename)
writefile("File uploaded: " + newfileloc)
myfile.SaveAs(newfileloc)
Return "success"
'Catch ex As Exception
' writefile("****Error: " + ex.Message.ToString + "****")
' Return "fail"
'End Try
End Function
我没有一种简单的方法来运行git中显示的演示服务器,因此只是寻找方向以及我的代码是否在正确的区域。