@@ -21,25 +21,33 @@ Platforms: desktop, server
2121Security: network
2222
2323Example:
24- put empty into tForm
25- put "dave" into tName
26- put "hello" into tMessage
27- if libURLMultipartFormData (tForm, "name", tName, "message", tMessage) \
28- is not empty then
29- ##handle error and exit
30- end if
31- set the httpHeaders to line 1 of tForm
32- delete line 1 of tForm
33- put "<file>" & "C:/myfile.gif" into tFile
34- put "image/gif" into tType
35- put "binary" into tEnc
36- if libURLMultipartFormAddPart(tForm,"file", tFile, tType, tEnc) \
37- is empty then
38- ##handle error and exit
39- else
40- post tForm to url tURL
41- set the httpHeaders to empty
42- end if
24+ command UploadFileToServer pName, pMessage, pFilename
25+ put the httpHeaders into tOrigHeaders
26+ put empty into tForm
27+ put libURLMultipartFormData (tForm, "name", pName, "message", pMessage) into tError
28+
29+ if tError is empty then
30+ set the httpHeaders to line 1 of tForm
31+ delete line 1 of tForm
32+ put "<file>" & pFilename into tFile
33+ put "image/gif" into tType
34+ put "binary" into tEnc
35+ put libURLMultipartFormAddPart(tForm,"file", tFile, tType, tEnc) into tError
36+ end if
37+
38+ if tError is empty then
39+ post tForm to url tURL
40+ put the result into tError
41+ end if
42+
43+ set the httpHeaders to tOrigHeaders
44+
45+ if tError is not empty then
46+ return tError for error
47+ else
48+ return empty for value
49+ end if
50+ end UploadFileToServer
4351
4452Parameters:
4553value:
0 commit comments