FTP/Upload help

Hello all,
I am using Graham Ranson FTP Helper with the following code:
However, it does not seem to work on device? anyone have any idea why?
I can check in simulator and if I use documents directory with sim it works and I verify
that it indeed uploads using simulator, but not with device using resources directory.
EDIT: I fixed it by changing resources directory to documents directory.

The Issue I have now is, how can you code it so that if the filename exists on the server, it will
upload the files and add/append the filename so that multiple users can upload files without over writing
the same files?

[lua]local ftp = require(“ftp”)

local connection = ftp.newConnection{
host = “0.0.0.0”,
user = “********”,
password = “****************”,
port = 21 – Optional. Will default to 21.
}

local onUploadSuccess = function(event)
print("File uploaded to " … event.path)
end

local onDownloadSuccess = function(event)
print("File downloaded to " … event.path)
end

local onAppendSuccess = function(event)
print(“File appended”)
end

local onError = function(event)
print("Error: " … event.error)
end

local function menuitem5( event )
connection:upload{
localFile = system.pathForFile(“bfactsdata.ice”, system.ResourcesDirectory),
remoteFile = “/public_html/bfactsdata.ice”,
onSuccess = onUploadSuccess,
onError = onError
}
connection:upload{
localFile = system.pathForFile(“entireGroup.jpg”, system.ResourcesDirectory),
remoteFile = “/public_html/entireGroup.jpg”,
onSuccess = onUploadSuccess,
onError = onError
}
return true
end
cameraicon:addEventListener(“tap”, menuitem5)[/lua] [import]uid: 58922 topic_id: 33916 reply_id: 333916[/import]

EDIT: I fixed it by changing resources directory to documents directory.

The Issue I have now is, how can you code it so that if the filename exists on the server, it will
upload the files and add/append the filename so that multiple users can upload files without over writing
the same files? [import]uid: 58922 topic_id: 33916 reply_id: 134872[/import]

Hey Brian, I was just finally able to reply to your email :slight_smile: Regarding the filename issue, you could set the filename to something like “currentTime-bigRandomNumber.jpg” so it would be very rare for a collision to occur. Like so:

[code]

local filename = os.time … “-” … math.random( 1, os.time() ) … “.jpg”
[/code] [import]uid: 119420 topic_id: 33916 reply_id: 134880[/import]

EDIT: I fixed it by changing resources directory to documents directory.

The Issue I have now is, how can you code it so that if the filename exists on the server, it will
upload the files and add/append the filename so that multiple users can upload files without over writing
the same files? [import]uid: 58922 topic_id: 33916 reply_id: 134872[/import]

Hey Brian, I was just finally able to reply to your email :slight_smile: Regarding the filename issue, you could set the filename to something like “currentTime-bigRandomNumber.jpg” so it would be very rare for a collision to occur. Like so:

[code]

local filename = os.time … “-” … math.random( 1, os.time() ) … “.jpg”
[/code] [import]uid: 119420 topic_id: 33916 reply_id: 134880[/import]