Reading the file is simple. There are API calls like io.open() which will let you read the file into a variable. Once you have that you can upload the file. More on that in a bit. Lets get the file read first:
local function readFile( filename, directory ) local dir = system.DocumentsDirectory if directory then dir = directory end local path = system.pathForFile( filename, dir ) local contents = "" local file = io.open( path, "rb" ) if file then -- read all contents of file into a string local contents = file:read( "\*a" ) io.close( file ) return contents end print(filename, "file not found") return nil, "File not found" end local myExcelSpreadsheet = readFile( "mydata.xlsx", system.DocumentsDirectory )
Now you have your contents in a variable you can work with.
Sending data to a server is tricky. Your receiving script will have its rules on how it expects the data sent to it. It could be a simple HTTP PUT request with the binary data sent in stream. It could be a multi-part MIME HTML form handler that expects the headers and body of a POST request to be setup in particular method. The script could just be looking for binary data or it could be expecting it to be MIME Base64 encoded. Since I have no clue about your server script you may have to figure this out on your own.
Our network.upload() API will work in the simple case of HTTP PUT requests and binary data sent in the stream. It’s really just a wrapper around network.request(). If you need POST and access to control the headers and such, you will use network.request() instead.
See: https://coronalabs.com/blog/2014/02/25/tutorial-uploading-files-demystified/
Rob