php - POST request with data specified in text file via CURL? -


i have simple cms based on css,html , php witout db. made curl script update content, including templates (mix of text , html) via post.

curl_setopt ($upload, curlopt_postfields, $postfields);  

and &postfields:

$postfields["person"] = "kris"; $postfields["action"] = "update"; $postfields["page"] = "name of page"; $postfields["newcontent"] = $post; 

+

$post=file_get_contents("update.txt"); 

what need send via post data specified in text file (update.txt) including mix of html/css/php.i don't want upload single file post content idea? :) thanks!

updated using questions field names , setting mimetype file

according send file via post curl , php , php manual following:

    $file_name_with_full_path = realpath('update.txt');      $postfields = array('person' => 'kris',         'action' => 'update',         'page' => 'name of page',         'newcontent'=>'@'.$file_name_with_full_path.';type=html');      $ch = curl_init();      curl_setopt($ch, curlopt_url,$target_url);     curl_setopt($ch, curlopt_post,1);     curl_setopt($ch, curlopt_postfields, $postfields);      $result = curl_exec ($ch);     curl_close ($ch);     echo $result; 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -