php - File upload using application/json in POST method -
i using following code send file api developing using application/json method.
$file_content = file_get_contents($file_path); $file_api_parameter["file".$i] = base64_encode($file_content);
but have heard sending file in manner causes problem if file size large.
can tell me, how send large file api using application/json post method?
code send post given below
$jsondata = json_encode($parameter); $post_response = wp_remote_post( $url, array( "method" => "post", "timeout" => 45, "headers" => $headers, "body" => $jsondata, "sslverify" => false ));
update -- files types want upload .pdf, .doc , .txt. right able upload .txt .pdf , .doc api method fails. because file content sent in post becomes large on encoding value. tracing request sent api using runscope application. here able trace response sent out api method. if try decode output using online decode tools able generate files back. request not reach api in case of .doc , .pdf file uploads.
refer link may idea http://codular.com/javascript-ajax-file-upload-with-progress
Comments
Post a Comment