Android Question Uploading multiple files to a .Net server path

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi Guys,

I am trying to upload miscellinous multiple files from device to a .net server path but without any luck.
Can anyone guide pls?

Thanks
Juzer
 

DonManfred

Expert
Licensed User
Longtime User
Can anyone guide pls?
How did you try it? Show your code.

Without seeing your code we hardly can give any congrete answer.

Usually the correct way is to use okHTTPs MultipartPost-Method.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi DonManfred,

Thanks for replying.
Below is the code i tried to use.
I changed the path to my server.
I guess content type needs to be chaged ??


Dim fd As FileData
If firsttime Then
hc.Initialize("hc")
End If
'Activity.LoadLayout("main")
'Add files
Dim files As List
files.Initialize
Dim fd As FileData
fd.Initialize
fd.Dir = File.DirAssets
fd.FileName = "star.png"
fd.KeyName = "Aufnahme"
fd.ContentType = "application/octet-stream"
files.Add(fd)
'Add second file
Dim fd As FileData
fd.Initialize
fd.Dir = File.DirAssets
fd.FileName = "glue.png"
fd.KeyName = "coca_cola"
fd.ContentType = "application/octet-stream"
files.Add(fd)
'Add name / values pairs (parameters)
Dim NV As Map
NV.Initialize
NV.Put("note1", "abc")
NV.Put("note2", "def")
NV.Put("action", "upload")
Dim req As OkHttpRequest
req = MultiPartPost.CreatePostRequest("http://www.myserver.com/UploadFile.aspx", NV, files)
hc.Execute(req, 1)

Server Side :
protected void Page_Load(object sender, EventArgs e)
{
{
HttpFileCollection uploadFiles = Request.Files;

string summary = "<p>Files Uploaded:</p><ol>";

int i;
for (i = 0; i < uploadFiles.Count; i++)
{
HttpPostedFile postedFile = uploadFiles;


System.IO.Stream inStream = postedFile.InputStream;
byte[] fileData = new byte[postedFile.ContentLength];
inStream.Read(fileData, 0, postedFile.ContentLength);

postedFile.SaveAs(Server.MapPath("App\\Images") + "\\" + postedFile.FileName);

}

}

I dont get any error and file also is not uploading.
Juzer
 
Upvote 0
Top