Like Rob said, probably the first thing to do is check the event.isError when the server calls back with the result… If it asynchronous, ie; your app just wants to check whenever, like the instant the user hits a button (and you don’t want to wait for a laggy or missed server response), then maybe something like:
function doesExist(theFile) -- checks for file we got from server in temporary dir
local retVal = false
local path = system.pathForFile( theFile, system.TemporaryDirectory )
if( path ) then
-- print("\*\*\*\*\* Path for File ==", path)
local fh, errStr = io.open( path, "r" )
if( fh ) then
local fileLength = fh:seek("end")
-- print(" -- fileLength == ", fileLength )
if( fileLength \> 512 ) then -- Our server returns an html file with message 404 error that is about 400 bytes long if graphic file requested is NOT there... so check for length of the file that server returned...
retVal = true -- Tell the caller that the file DOES exist...
end
io.close(fh) -- close the file...
end
end
return retVal
end
Oh, also, I found out about the 404 file not found html issue with my file server by using the corona simulator on the mac. You can open the sandbox, and see your apps temporary directory… All the files it creates as it runs, and open them with your mac apps to look them over. Quite handy. Don’t use the windows simulator, but I’d imagine you can do the same thing. [import]uid: 79933 topic_id: 35385 reply_id: 140710[/import]