Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/CURLS post form/CURLS post form
Function:
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 post form/CURLS post form
This example is the version from Wed, 14th Jul 2015.
Project "CURLS post form.rbp"
FileTypes
Filetype text
Filetype all
End FileTypes
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim f as FolderItem dim b as BinaryStream f=GetOpenFolderItem("all") if f<>nil then b = BinaryStream.Open(f) if b<>Nil then stream=b file=f PathText.text=f.AbsolutePath end if end if End EventHandler
End Control
Control PathText Inherits Label
ControlInstance PathText Inherits Label
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() DoUpload End EventHandler
End Control
Control Result Inherits TextField
ControlInstance Result Inherits TextField
End Control
EventHandler Sub Open() dim f as FolderItem dim b as BinaryStream f=SpecialFolder.Desktop.Child("UploadTest.rbp.zip") if f<>nil then b = BinaryStream.Open(f) if b<>Nil then stream=b file=f PathText.text=f.AbsolutePath end if end if End EventHandler
Private Sub DoUpload() dim e as integer dim buf as string dim d as UploadCURL const CURLFORM_NOTHING = 0 const CURLFORM_COPYNAME = 1 const CURLFORM_PTRNAME = 2 const CURLFORM_NAMELENGTH = 3 const CURLFORM_COPYCONTENTS = 4 const CURLFORM_PTRCONTENTS = 5 const CURLFORM_CONTENTSLENGTH = 6 const CURLFORM_FILECONTENT = 7 const CURLFORM_ARRAY = 8 const CURLFORM_FILE = 10 const CURLFORM_BUFFER = 11 const CURLFORM_BUFFERPTR = 12 const CURLFORM_BUFFERLENGTH = 13 const CURLFORM_CONTENTTYPE = 14 const CURLFORM_CONTENTHEADER = 15 const CURLFORM_FILENAME = 16 d=new UploadCURL d.OptionURL=url.text d.OptionVerbose=True d.CollectDebugData = true d.CollectHeaderData = true d.CollectOutputData = true buf=stream.Read(stream.Length) // add a section named filMyFile // with a file named file.name // and binary content in buf d.FormAdd(d.kFormCopyName,"myfile", d.kFormBuffer, file.Name, d.kFormBufferPtr, buf, d.kFormBufferLength, lenb(buf)) d.FormFinish e=d.Perform ListBox1.AddRow "Result: "+str(e) ListBox1.AddRow d.GetInfoContentType Result.text=d.OutputData End Sub
Property Protected file As folderitem
Property Protected stream As binaryStream
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 Sub DebugMessage(infotype as integer, data as string, dataSize as Integer) System.DebugLog str(infotype) System.DebugLog data End EventHandler
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64) As boolean if ultotal=0 then window1.ListBox1.AddRow "Uploading..." else window1.ListBox1.AddRow "Uploading "+Format(ulnow/ultotal,"0%") end if End EventHandler
Sub Constructor() End Sub
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS CURL Plugin.




Links
MBS Xojo PDF Plugins