Yes, I watched the controls training and studied the progress bar part very carefully. I cannot extrapolate what I need from it in this case.
The user needs to upload files to the file server and I thought a progress bar would make a nice touch.
Here is the code that uploads the ftp files and FTPs.
=================================
-- was invisible, now show it.
show the sb "prgScrollBar"
set the startvalue of sb "prgScrollBar" to 1
# Start by getting the file to upload
local tFileForUpload, tFileName
answer file "Select a file to upload"
put it into tFileForUpload
# Get the name of the file for upload
set the itemdel to "/"
put the last item of tFileForUpload into tFileName
put empty into field 1
put empty into field "fldRef1"
# Connect the start the upload
local tDestination
put "http://www." & "travelandworkusa.com" &FilePath &tFileName into tFieldDest
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "ftp.travelandworkusa.com" &FilePath & tFileName into tDestination
libURLSetStatusCallback "uploadProgress", the long ID of me
libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"
put tFieldDest into field "fldRef1"
end mouseUp
on uploadComplete pURL, pStatus
put "Status Update:" && pStatus && return after field "lblHints"
set the thumbpos of sb "prgScrollBar" to xyz
end uploadComplete
on uploadProgress pURL, pStatus
put "Status Update:" && pStatus && return before field "lblHints"
set the thumbpos of sb "prgScrollBar" to xyz
end uploadProgress
=========================================
Is this line
set the thumbpos of sb "prgScrollBar" to xyz
in the right place and how do I 'plug it in' to the value of the ftp upload?
I need to figure out the end position of the progress bar by finding out the total size of the file being uploaded - how do I do this?
Mike
Trying to get a progress bar working for a ftp upload
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Trying to get a progress bar working for a ftp upload
You need to look at libURLSetStatusCallback in the dictionary a little more, but you are getting there I think.
From the docs:
Then you should be able to take item 2 of pStatus and apply the same division, and use that to set the thumbPos.
From the docs:
So in your uploadProgress handler you can check if item 1 of pStatus is "uploading" then item 3 should tell you how large the file is. You can then use that to calculate and set the endValue of the scrollbar. (Note that the maximum endValue is 65535, and as the status parameter returns the number of bytes for the size of the file, you will probably have to do some dividing by 10s/100s/1000s to get a value within range. You may also want to set a flag that indicates the endValue has already been calculated and set, to avoid needless resetting of the endValue each time the handler is called.)The URL status parameter is similar to the status returned by the URLStatus function, and is one of the following:
"queued": on hold until a previous request to the same site is completed
"contacted": the site has been contacted but no data has been sent or received yet
"requested": the URL has been requested
"loading,bytesReceived,bytesTotal": the URL data is being received
"uploading,bytesReceived,bytesTotal": the file is being uploaded to the URL
"downloaded": the application has finished downloading the URL
"uploaded": the application has finished uploading the file to the URL
"error": an error occurred and the URL was not transferred
"timeout": the application timed out when attempting to transfer the URL
empty: the URL was not loaded, or has been unloaded
Then you should be able to take item 2 of pStatus and apply the same division, and use that to set the thumbPos.
Re: Trying to get a progress bar working for a ftp upload
Mike, please stop opening two threads for the same topic, thanks!admin12 wrote:Anyone?
Mike
And I will move this thread to the "Internet" forum.
Re: Trying to get a progress bar working for a ftp upload
Here is a small example.
Be sure to set your parameters (ftp server address, login and password) in the stack script.
Be sure to set your parameters (ftp server address, login and password) in the stack script.
- Attachments
-
- UPLOADFTP.zip
- (4.64 KiB) Downloaded 512 times