This method uploads data in a byte array to a file on the remote server specified by a scheme, host name, and path.
[Visual Basic] Public Function
UploadByteArrayToFile(ByVal scheme As String, ByVal remoteHost As
String, ByVal remotePath As String, ByVal ByVal data As Byte()) As
Boolean
[C#] public bool UploadByteArrayToFile(string
scheme, string remoteHost, string remotePath, byte[] data);
Parameters
scheme
Internet Access Protocol ("http" or "https")
remoteHost
DNS style domain name or IP address
remotePath
The upload path on the remote server
data
Data in byte array
Return Value
Returns True if successful, otherwise returns False
Explanation
The UploadByteArrayToFile method uploads data in a byte array to a file on the remote server specified by a scheme, host name, and path.
This method is enabled for HTTP or HTTPS protocol.
Example
[Visual Basic.NET]
Dim _http As New Newtone.ImageKit.WPF.Http
Dim Ret As Boolean
'Username and password
_http.Credentials = New NetworkCredential("user", "password")
'When using "POST"
_http.Method = "POST"
_http.Headers.Set("Content-Disposition", "form-data; name=""file""; filename=""test.jpg""")
Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/upload.php", data)
'When using "PUT"
'_http.Method = "PUT"
'Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/test.jpg", data)
[Visual C#.NET]
Newtone.ImageKit.WPF.Http _http = new Newtone.ImageKit.WPF.Http();
bool Ret;
//Username and password
_http.Credentials = new NetworkCredential("user", "password");
//When using "POST"
_http.Method = "POST";
_http.Headers.Set("Content-Disposition", "form-data; name=\"file\"; filename=\"test.jpg\"");
Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/upload.php", data);
//When using "PUT"
//_http.Method = "PUT";
//Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/test.jpg", data);
Dim _http As New Newtone.ImageKit.WPF.Http
Dim Ret As Boolean
'Username and password
_http.Credentials = New NetworkCredential("user", "password")
'When using "POST"
_http.Method = "POST"
_http.Headers.Set("Content-Disposition", "form-data; name=""file""; filename=""test.jpg""")
Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/upload.php", data)
'When using "PUT"
'_http.Method = "PUT"
'Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/test.jpg", data)
[Visual C#.NET]
Newtone.ImageKit.WPF.Http _http = new Newtone.ImageKit.WPF.Http();
bool Ret;
//Username and password
_http.Credentials = new NetworkCredential("user", "password");
//When using "POST"
_http.Method = "POST";
_http.Headers.Set("Content-Disposition", "form-data; name=\"file\"; filename=\"test.jpg\"");
Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/upload.php", data);
//When using "PUT"
//_http.Method = "PUT";
//Ret = _http.UploadByteArrayToFile("http", "www.newtone.co.jp", "test/test.jpg", data);
See Also