Ja, det er en alm. aspx side. men det er jo kun for at kunne teste om min service fil "fanger" den fil jeg forsøger at uploade med ajax. Som jeg skrev så er det via en app. Men eftersom jeg får en fejl på service filen om at den ikke forstår formatet, så ville jeg have en side til at teste om det var den ene eller den anden del der fejler. Og hvis nogen så havde et eksempel på en service som kunne netop det, så ville det være perfekt.
Jeg kan indsætte koden her, og så kan du måske se om der er oget som skal rettes.
Det er så godt nok VB.
Og det skal ikke nødvendigvis være en PNG fil.
Ville du kunne omskrive denne så den passer til det jeg har beskrevet?
-----------------
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.IO
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="
http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class imageUpload
Inherits System.Web.Services.WebService
'<WebMethod()> _
'Public Function HelloWorld() As String
' Return "Hello World"
'End Function
<WebMethod(Description:="Upload a file from a POSTed web form.")> _
Public Function UploadFileCollection() As String
Dim fileName As String = ""
Dim vFileType As String = ""
Dim vFileExt As String = ".png"
Dim metaBuffer As String = ""
Dim aDate As DateTime = DateTime.Now
Dim metaname As String = aDate.Ticks.ToString()
Dim vContentType As String
Try
'HTTP Context to get access to the submitted data
Dim postedContext As HttpContext = HttpContext.Current
'File Collection that was submitted with posted data
Dim Files As HttpFileCollection = postedContext.Request.Files
fileName = "upload_image_" & metaname
If Files.Count = 1 AndAlso Files(0).ContentLength > 1 AndAlso fileName IsNot Nothing AndAlso fileName <> "" Then
'The byte array we'll use to write the file with
Dim binaryWriteArray As Byte() = New Byte(Files(0).InputStream.Length - 1) {}
'Read in the file from the InputStream
Files(0).InputStream.Read(binaryWriteArray, 0, CInt(Files(0).InputStream.Length))
vContentType = Files(0).ContentType
'Open the file stream
Dim objfilestream As New System.IO.FileStream(Server.MapPath("/upload/" & fileName & vFileExt), FileMode.Create, FileAccess.ReadWrite)
'Write the file and close it
objfilestream.Write(binaryWriteArray, 0, binaryWriteArray.Length)
objfilestream.Close()
Return "success: " & fileName
Else
Return "failed "
End If
Catch ex1 As Exception
Throw New Exception("Problem uploading file: " & ex1.Message & " f: " & fileName)
End Try
End Function
End Class
-----------------