第一個報(bào)錯,當(dāng)我正確配置證書了,就出現(xiàn)第二個報(bào)錯了
cURL error 60: SSL certificate problem: self signed certificate in certifica 【已解決】
第二個報(bào)錯
ErrorException: Array to string conversion in C:\draw_webman\webman\vendor\workerman\workerman\Protocols\Http.php:209
Stack trace:【未解決】
證書配置檢查多次確信無誤
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="D:/phpstudy_pro/Extensions/php/php7.4.3nts/extras/ssl/cacert.pem"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile="D:/phpstudy_pro/Extensions/php/php7.4.3nts/extras/ssl/cacert.pem"
框架報(bào)錯行數(shù)
這里寫具體的系統(tǒng)環(huán)境相關(guān)信息
備注:自己已檢測業(yè)務(wù)代碼,不應(yīng)該是業(yè)務(wù)代碼錯誤,業(yè)務(wù)代碼是從原生tp5復(fù)制過來的
//上傳圖片
public function upload(Request $request)
{
$file = $request->file('file');
if ($file && $file->isValid()) {
$info = $file->move(public_path().'/files/myfile.'.$file->getUploadExtension());
$fi = './public/files/myfile.'.$file->getUploadExtension();
$savePath = time().mt_rand(100000,999999).'.png';
//將圖片傳到騰訊云
$local_path = $fi;//文件上傳臨時目錄
//摳圖完成上傳騰訊云,加快下載速度
$server_key_name = '/photo/'.date("Ymd",time()).'/'.date("YmdHis",time()).$savePath;//遠(yuǎn)程服務(wù)器存儲的名字
require './vendor/autoload.php';
$secretId = "XXX"; //"云 API 密鑰 SecretId";
$secretKey = "XXX"; //"云 API 密鑰 SecretKey";改成自己的
$region = "ap-nanjing"; //設(shè)置一個默認(rèn)的存儲桶地域
$cosClient = new \Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', //協(xié)議頭部,默認(rèn)為http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)
)
);
//定義數(shù)據(jù)
$upload_success = false;
$img_url = '';
$upload_msg = '';
try {
$result = $cosClient->upload(
$bucket = 'xxx-123', //請創(chuàng)建桶的時候 設(shè)置公共讀寫 改成自己的
$key = $server_key_name,
$body = fopen($local_path, 'rb')
);
// 請求成功,返回透明前景
$data = $result->toArray() ;
return $data;
if(isset($data['Location']) && isset($data['Key'])){
$img_url = 'https://'.$data['Location'];
$upload_success = true;
}
} catch (\Exception $e) {
// 請求失敗
$upload_msg = $e->getMessage();
return $upload_msg;
}
//合成成功
$data = ['img_url'=>$img_url];
return $data;
}
}
上傳圖片的業(yè)務(wù)代碼,在我原生tp5里面執(zhí)行正常,復(fù)制到webman,報(bào)框架錯誤,框架錯誤讓我無從下手,有人遇到此類情況嗎?
關(guān)鍵字 Array to string... ,數(shù)組不能轉(zhuǎn)換為字符串??刂破骼飏eturn array應(yīng)該是錯誤用法,改成 return json($data); 試下