Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/CURLS upload to Web App/CURLS upload to Web App
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS upload to Web App/CURLS upload to Web App
This example is the version from Sat, 25th Apr 2014.
Project "CURLS upload to Web App.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
DoUpload
End EventHandler
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control iURL Inherits TextField
ControlInstance iURL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run()
CURL = new UploadCURL
// uncomment all to upload 200 MB for testing
'dim m as new MemoryBlock(200000000)
'm.FillBytesMBS 0, m.size, 65
'dim s as string = m
// this is the file content here:
CURL.InputData = "Just a little bit text. Have fun!" '+s
CURL.OptionURL = URL
CURL.OptionUpload=true
CURL.YieldTime = true
PerformError = CURL.Perform
CURL.Finish = true
End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
if curl = nil then Return
while CURL.messages.Ubound >= 0
listbox1.AddRow curl.messages(0)
curl.messages.Remove 0
wend
if curl.Finish then
listbox1.addrow "Result: "+str(PerformError)
curl = nil
end if
End EventHandler
End Control
Private Sub DoUpload()
URL = IUrl.text
thread1.run
End Sub
Property CURL As UploadCURL
Property Private PerformError As Integer
Property URL As string
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class UploadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as double, dlnow as double, ultotal as double, ulnow as double) As boolean
dim m as string
if ultotal=0 then
m = "Uploading..."
else
m = "Uploading "+Format(ulnow/ultotal,"-0%")+" "+stR(ulnow)+" of "+str(ultotal)
end if
messages.append m
End EventHandler
Property Finish As Boolean
Property messages() As string
End Class
End Project
See also:
- /CURL/CURLS get and put/CURLS get and put
- /CURL/CURLS LDAP Query
- /CURL/CURLS Low Level Sockets
- /CURL/CURLS post form/CURLS post form
- /CURL/CURLS preemptive threaded upload
- /CURL/CURLS query
- /CURL/CURLS simple download compressed
- /CURL/CURLS simple file download
- /CURL/CURLS text download
- /CURL/CURLS upload to Web App/Web Upload Receiver
The items on this page are in the following plugins: MBS CURL Plugin.