Welcome Guest, Not a member yet? Register   Sign In
cURL library multipart/form-data POST problem.
#1

[eluser]rschla104[/eluser]
I'm using the cURL library by Phil Sturgeon and CI 1.7.3.

I've got my cURL POST call in a library function so that I can call it multiple times easily. In the submit function of the controller, I pass it in the information from the form. Here is the function in the library.

Code:
function publishCourse($dest, $course_id, $filepath){
        
        $campusId = $dest->campus_id;
        $url = $urlToPostTo.'extractor.jsp';
        $uploadFile = '@'.$filepath.';type=application/zip';

        $postData = array('courseId'=>''.$course_id, 'campusId'=>''.$campusId, 'uploadFile'=>$uploadFile);
        
        $successful = $this->CI->curl->simple_post($url, $postData);

        return $successful;
        
    }

The receiving .jsp is using the O'Reilly MultipartRequest library to process the POST. It is giving me an error saying that Posted content type isn't multipart/form-data. I have control of the receiving jsp so I can make changes on that end as well. I'm stumped. According to cURL, it seems that just by adding the filename with the '@' prefix and putting it in the array, it should automatically post as multipart/form-data.

*edit* $urlToPostTo is just a variable because I couldn't write the actual url in the post.




Theme © iAndrew 2016 - Forum software by © MyBB