0

I have a simple CMS based on css,HTML and PHP witout DB. I made a cURL script to update the content, including templates (mix of text and HTML) via POST.

curl_setopt ($upload, CURLOPT_POSTFIELDS, $postfields); 

and &postfields:

$postfields["person"] = "Kris";
$postfields["action"] = "Update";
$postfields["page"] = "Name of the page";
$postfields["newcontent"] = $post;

+

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

What I need is to send via POST data specified in text file (update.txt) including a mix of html/css/php.I don't want to upload a single file just POST its content Any idea? :) Thanks!

4

2 回答 2

1

使用问题字段名称更新并为文件设置 Mimetype

根据使用 cURL 和 PHP 通过 POST 发送文件以及PHP 手册,您可以执行以下操作:

    $file_name_with_full_path = realpath('update.txt');

    $postfields = array('person' => 'Kris',
        'action' => 'Update',
        'page' => 'Name of the 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;
于 2013-08-28T18:05:10.220 回答
0

排序:)

$postfields["newcontent"] = $post;

+

$newcontent = 'post.txt';
$post = file_get_contents($newcontent);
于 2013-08-28T18:48:35.747 回答