Reputation: 91
In R, I would like to upload a file to a server through a POST request. I use RCurl package, but I am ready to use another package if it could solve the problem.
The code I have so far is the following, but it does not work, as explained in the comments at the end of the code:
library("RCurl")
uri <- "https://www.xxx.com/yyy.php?auth=2"
file.name <- "D:\\temp_pic_2013-11-09_17_14_41.png"
result1 <- postForm(uri, theFile = fileUpload(filename = file.name, contentType="image/png"), .opts = list(ssl.verifypeer = FALSE))
# result1 contains the following whereas it should contain the url of the uploaded pic:
# [1] "Error processing request"
# attr(,"Content-Type")
#
# "text/html"
Note: I succeeded in uploading files on the same server with a Java code, so the problem is very probably within my R code and not on the server side.
Thanks in advance for your help,
Nicolas
Upvotes: 1
Views: 1400
Reputation: 91
Problem solved.
theFile = fileUpload(...) should be replaced by file= fileUpload(...)
The solution was on the configuration of the server side.
Nicolas
Upvotes: 1