Frequently Asked Questions

The FAQ list is a great starting point for basic questions about what you can do with Robo-FTP.

Orange_arrowOrange_arrow Browse the FAQ list now

Knowledge Base

Our searchable knowledge base covers most of the common errors and implementation problems you are likely to encounter.

Orange_arrowOrange_arrow Search the Knowledge Base now

Contact Technical Support

If you can't find the answers you need online, get in touch with our Technical Support staff.

Orange_arrowOrange_arrow Contact Technical Support now

Professional Services

Need more than basic technical support? Our Professional Services team can help you deploy a complete solution.

Orange_arrowOrange_arrow Contact Professional Services now

Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.


http_post_file.s

Download

As of v3.6.0, Robo-FTP supports automating communication via HTTP and HTTPS.

One of the more complicated scenarios to automate is the process of communicating interactively with a web site and uploading data via a web form.

This script provides some functions that greatly simplify this task.

HTTP web forms come in 2 basic varieties:

application/x-www-form-urlencoded

This is the default type of form. It can be submitted using either an HTTP GET or an HTTP POST.

Submit via GET

This type is less common and is not the focus of this sample. Automating this type of form is very easy. You simply need to construct a url of the form:

 http://www.myurl.com?field=value&field=value&field=value

This can be accomplished with a simple two-line Robo-FTP script:

 FTPLOGON "www.myurl.com" /servertype=HTTP
 RCVFILE "?field=value&field=value&field=value" "localfilename.html"

This type of form can only be used for submitting ASCII characters.

Submit via POST

This is the most common type of form submission and is also used to submit ASCII characters in field=value pairs as above. The only difference is instead of appending the form data to the url, the data is added to the body of the POST.

The sample script below includes functions for encoding the data properly and submitting the form.

multipart/form-data

This type must be explicitly specified in the <form> tag's enctype attribute like this:

 <form action="http://www.myurl.com" method="post" enctype="multipart/form-data">

This type of form submits data via POST as described above, but can also include a file upload. This is the only type of form that can cover the entire ISO10646 character set.

Uploading a file via this type of form is defined in RFC 2388.

This sample script includes functions that simplify the process of encoding a file upload into the body of the form and submitting it.


  1  BEGINFUNCTIONS
  2    FUNCTION InitPostData file boundary
  3      SET %myfile = file
  4      SET %myboundary = "--" & boundary
  5      SET %contenttype = "Content-Type: multipart/form-data, boundary=" & boundary
  6      WRITEFILE file %myboundary    
  7    ENDFUNCTION
  8    FUNCTION AddPostField name value 
  9      SET %header = 'content-disposition: form-data; name="' & name & '"'
 10      WRITEFILE %myfile %header /append
 11      WRITEFILE %myfile "" /append
 12      WRITEFILE %myfile value /append
 13      WRITEFILE %myfile %myboundary /append
 14      RETURN
 15    ENDFUNCTION
 16    FUNCTION AddPostFile fieldName file mimeType
 17      SETSUBSTR depth = file "\"
 18      SETNUM depth = depth + 1
 19      SETEXTRACT base = file "\" depth
 20      SET %header = 'content-disposition: form-data; name="' & fieldName & '"; filename="' & base & '"'
 21      SET %mimeHeader = 'Content-Type: ' & mimeType
 22      SET %headFile = %myfile & ".head"
 23      SET %tailFile = %myfile & ".tail"
 24      WRITEFILE %myfile %header /append
 25      WRITEFILE %myfile %mimeHeader /append
 26      WRITEFILE %myfile "Content-Transfer-Encoding: binary" /append
 27      WRITEFILE %myfile "" /append
 28      RENAME %myfile %headFile
 29      WRITEFILE %tailFile %myboundary
 30      SET %command = "copy /b " & %headFile & " + " & file & " + " & %tailfile & " " & %myfile
 31      DOSCMD %command
 32      DELETE %headFile
 33      DELETE %tailFile
 34    ENDFUNCTION
 35  ENDFUNCTIONS
 36  
 37  ;; You should not need to edit anything above this line.
 38  ;; Just set the variables below as appropriate and call
 39  ;; the above functions as demonstrated below.
 40  
 41  SET %tmpdata = "C:\post.bin"
 42  SET %field1 = "field1 value"
 43  SET %field2 = "field2 value"
 44  SET %filename = "C:\files\files.zip" 
 45  ; mimetype below should be based on extension (zip)
 46  SET %mimetype = "application/zip"
 47  ; see http://www.mimetype.org/ or use application/octet-stream
 48  
 49  FTPLOGON "HTTP Site"
 50  ; prepare post data for upload
 51  InitPostData %tmpdata "lakfiqalwuFieldSeperator48pyq489pyq"
 52  AddPostField "field1" %field1
 53  AddPostField "field2" %field2
 54  AddPostFile "userfile" %filename %mimetype
 55  HTTPPOST "/poster.asp" %tmpdata %postresult /outtype=string /contenttype=%contenttype
 56  DELETE %tmpdata
 57  FTPLOGOFF

Browse complete list of scripts