Multiple File Upload - WeOnlyDo Discussion board

Multiple File Upload (General questions)

by michael090, Friday, November 12, 2004, 08:10 (7113 days ago)

I'm having problem with uploading multiple files is there's a way to queue file to be uploaded?

Dim filepath As IO.Directory
Dim filearray As Array
Dim filename As String
Dim filefolder As String
Dim i As Integer
'Sftp1.Blocking = False
filefolder = filepath.GetCurrentDirectory()
filearray = filepath.GetFiles(txtLocalPath.Text)
For i = 0 To filearray.Length - 1
filename = filearray(i)
If Sftp1.State.SendingFile.Executing Then
AddToList(vbCrLf & ***UPLOADING file & txtmsg.Text)
Sftp1.PutFile(filename, /home/test )
End If
upload(filename)
Next[:smile:][:smile:]

Re: Multiple File Upload

by wodSupport, Friday, November 12, 2004, 13:13 (7113 days ago) @ michael090

Can you make sure Sftp1.Blocking = True? Your code looks ok to me - assuming Blocking is set. Can you try that?

Re: Multiple File Upload

by michael090, Tuesday, November 16, 2004, 01:53 (7110 days ago) @ wodSupport

I already try to set SFTP1.Blocking=true but my program hangs...

Re: Multiple File Upload

by wodSupport, Tuesday, November 16, 2004, 01:55 (7109 days ago) @ michael090

Can you please make standalone sample that duplicates your problem, then zip it and send to techsupport@weonlydo.com ? I'd like to try it out - it cannot hang with no reason, and I need to see full code in order to give you more details.

Possible?

Re: Multiple File Upload

by michael090, Tuesday, November 16, 2004, 01:59 (7109 days ago) @ wodSupport

sure... wait for a minute.

Re: Multiple File Upload

by michael090, Tuesday, November 16, 2004, 02:26 (7109 days ago) @ michael090

Sir,
I'd already sent the zip file to your email.

Regards,
Dan

Re: Multiple File Upload

by wodSupport, Tuesday, November 16, 2004, 04:06 (7109 days ago) @ michael090

I looked at the source. Didn't try it yet but I think I see the problem. You are using Blocking *AND* events. You shouldn't be doing that. Let me explain.

Each command you call blocks. 'Connect' blocks. 'PutFile' blocks.

So, you call
1. Connect (your thread blocks),
2. we do something under the hood,
3. we fire 'Connected' event,
4. we unblock so you can proceeed.

now, imagine you call 'PutFile' between 3 and 4 - so you cause second blocking to occur - and app freezes.

In order to avoid this problem you should NOT execute blocking methods from within event code. So, you can
a) set Blocking = False and change your code a bit so it works in async manner (we call you when something is done)
b) move code from 'Connected' event to just after calling 'Connect' method.

Can you try that?

Re: Multiple File Upload

by michael090, Tuesday, November 16, 2004, 06:06 (7109 days ago) @ wodSupport

Sir,
I also find my problem why the program freeze when i try to upload multiple files. I tried to trigger the upload after the event of connected . That's why it always execute the upload function everything the Connected event was done....


Thanks for you big help...

Regards,
Dan