Did you try to create a list of all the image files first before uploading them. Perhaps something like this. See my added lines with the comment 'new:
Dim SQL1 As SQL
Dim sFTP As FTP_Auto
Dim waitTimer As Timer
Dim MyList as list 'New
Dim MyFile as String 'New
MyList.Initialize 'New
sFTP.Initialize(Activity,Me,"IPadresss","userID","password",21,True,False)
sFTP.SetCompletedUploadDialog(True,"Uploads Completed...")
SQL1.Initialize(File.DirInternal, "images.db", False)
Dim jC As Cursor
jC = SQL1.ExecQuery("SELECT * FROM images where uploaded='No'")
For i=0 To jC.RowCount-1
jC.Position=i
Buffer = jC.GetBlob("image")
Dim out2 As OutputStream
'' save real filename to the phone
out2 = File.OpenOutput(File.DirRootExternal, jC.GetString("picName"),False)
out2.WriteBytes(Buffer, 0, Buffer.Length)
MyList.add(jC.GetString("picName")) 'New
out2.Flush
out2.Close
waitTimer.Initialize("waitTimer",4000)
waitTimer.Enabled=True
Next
for i= 0 to myList.Size-1 'New
MyFile=Mylist.get(i) 'New
sFTP.UpLoadFile(File.DirRootExternal, "/visuals/",MyFile) 'New
next 'New
sFTP.Close
jC.Close
SQL1.Close
Thanks Mahares. But that didn't seem to work either. Found the answer though. The problem was in the way that the images were being inserted into the DB. I was copying the newly taken picture to:
InputStream1 = File.OpenInput(File.DirRootExternal, "image1.jpg")
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
File.Copy2( InputStream1, OutputStream1)
Dim Buffer() As Byte 'declares an empty array
Buffer = OutputStream1.ToBytesArray
SQL1.ExecNonQuery2("INSERT INTO images VALUES('" & sJobID & "','" & sPicName & "','" & Wid & "','" & Ht & "','" & _
su.EncodeUrl(sPicNotes,"UTF8") & "','No',?)", Array As Object(Buffer))
Using "image1.jpg" each time didn't work
Instead:
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, sPicName, False)
out.WriteBytes(Data, 0, Data.Length)
out.close
File.OpenOutput(File.DirRootExternal,sPicName,False)
InputStream1 = File.OpenInput(File.DirRootExternal, sPicName)
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
File.Copy2( InputStream1, OutputStream1)
Dim Buffer() As Byte 'declares an empty array
Buffer = OutputStream1.ToBytesArray
SQL1.ExecNonQuery2("INSERT INTO images VALUES('" & sJobID & "','" & sPicName & "','" & Wid & "','" & Ht & "','" & _
su.EncodeUrl(sPicNotes,"UTF8") & "','No',?)", Array As Object(Buffer))
SQL1.Close
InputStream1.Close
OutputStream1.Close
Probably some redundancy here, but it works.
Thanks again for your efforts.