-1

我得到错误:

警告:exec()出于安全原因已禁用

对于以下代码,关于如何在不使用的情况下解决此问题的任何想法exec()

$file = 'test.jpg';
$cmd  = 'curl -F userfile=$file ' .
        '-F outputencoding="utf-8" ' .
        '-F outputformat="txt" ' .
        'http://maggie.ocrgrid.org/cgi-bin/weocr/ocr_scene.cgi >result.txt';
exec($cmd, $result);
echo $result;
4

1 回答 1

0

尝试这个:

$url = 'http://maggie.ocrgrid.org/cgi-bin/weocr/ocr_scene.cgi';
$filename = 'test.jpg';

// postfields
$data = array(
    'userfile' => '@'.realpath($filename)
);

$fp1 = fopen('res_error.txt','w');
$fp2 = fopen('res_header.txt','w');

// cURL
$ch = curl_init();
curl_setpot_array($ch, array(
    CURLOPT_URL            => $url  ,
    CURLOPT_POSTFIELDS     => $data ,
    CURLOPT_CONNECTTIMEOUT => 60    ,
    CURLOPT_HEADER         => false ,
    CURLOPT_RETURNTRANSFER => true  ,
    CURLOPT_POST           => true  ,
    CURLOPT_VERBOSE        => true  ,
    CURLOPT_STDERR         => $fp1  ,
    CURLOPT_WRITEHEADER    => $fp2  ,
));
$res = curl_exec($ch);

fclose($fp1);
fclose($fp2);

echo $res;
于 2013-05-12T03:30:11.803 回答