HTTP Embedded Server: How To Upload/Download Text Files

Mahares

Expert
Licensed User
Longtime User
A Nexus 7 tablet serves as a HTTP server using HTTPServer Lib 1.0. In the ServerService module I use this code to download the file to other client devices when they access the server:
B4X:
Response.SendFile(File.DirRootExternal & "/POC","LP1051213061213.txt")
The file is downloadeded to the device’s ‘Download’ folder with a name: downloadfile.bin instead of LP1051213061213.txt which is the name in the server.
1. How can it be saved with the original server name and to a different folder other than ‘Download’ folder?
2. How can I upload files from a specific device folder to the server specific folder?
Thank you for helping a needy member.
 

Mahares

Expert
Licensed User
Longtime User
Does anyone that has used Erel's HTTP embedded server lib know how to send files from a specific device folder to the server specific folder? If I do not get any responses, I assume it is not doable. I will abandon the use of this lib.
Thanks to anyone who wants to take a shot at this.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Yes. I would like to upload a file to the server from another device. I want the file to originate in a specific folder and be saved to a specific folder on the server.
Merci Beaucoup
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I would like to upload a file called: Base_Comment.tab from a device: File.DirRootExternal to the server File.DirRootExternal. What do you replace in this code to make it work:
B4X:
Dim CurrentPath As String =File.DirRootExternal & "/Base_Comments.tab"
Dim upfile as string =File.DirRootExternal & "/Base_Comments.tab"

Dim upload As String = Request.GetUploadedFile("upfile")
   File.Copy(server.TempFolder, upload, CurrentPath, Request.GetParameter("upfile")) 
   File.Delete(server.TempFolder, upload)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel: I did not want to write any code at the client side. I just wanted the file to upload from the client File.DirRootExternal to the server File.DirRootExternal as soon as I open the browser, retaining the same file name on both ends. I am struggling with what the code should be in the server side without having to select a file from a list.
 
Upvote 0
Top