UploadFile is ansynchronous sub or not? You should wait for the UploadCompleted event before you delete the file
B4X:
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then
Log(LastException.Message)
else
' Delete your file here...
end if
End Sub