|
@@ -0,0 +1,52 @@
|
|
|
+==============此代码仅供参考======================
|
|
|
+
|
|
|
+=====php如何获取文件数据以及计算MD5Code=======
|
|
|
+
|
|
|
+php实例代码如下:
|
|
|
+ $len = strlen($this->params['biz_content']['fileData']);
|
|
|
+ $bytes = array();
|
|
|
+ for($i=0;$i<$len;$i++) {
|
|
|
+ if(ord($this->params['biz_content']['fileData'][$i]) >= 128){
|
|
|
+ $byte = ord($this->params['biz_content']['fileData'][$i]) - 256;
|
|
|
+ }else{
|
|
|
+ $byte = ord($this->params['biz_content']['fileData'][$i]);
|
|
|
+ }
|
|
|
+ $bytes[] = $byte;
|
|
|
+ }
|
|
|
+ $this->params['biz_content']['fileData'] = $bytes;//implode(',', $bytes);
|
|
|
+
|
|
|
+public function psbcFileUpload(){
|
|
|
+ $path = 'G:\guiyaun\20210506114611.jpg';
|
|
|
+ //方法一:
|
|
|
+ // $this->params['biz_content']['fileData'] = file_get_contents($path);
|
|
|
+ // $len = strlen($this->params['biz_content']['fileData']);
|
|
|
+ // $bytes = array();
|
|
|
+ // for($i=0;$i<$len;$i++) {
|
|
|
+ // if(ord($this->params['biz_content']['fileData'][$i]) >= 128){
|
|
|
+ //
|
|
|
+ // $byte = ord($this->params['biz_content']['fileData'][$i]) - 256;
|
|
|
+ // }else{
|
|
|
+ // $byte = ord($this->params['biz_content']['fileData'][$i]);
|
|
|
+ // }
|
|
|
+ // $bytes[] = $byte;
|
|
|
+ // }
|
|
|
+ //方法二:
|
|
|
+ $byteArray = unpack("c*",file_get_contents($path));
|
|
|
+ foreach ($byteArray as $k=>$v){
|
|
|
+ $bytes[] = $v;
|
|
|
+
|
|
|
+ }
|
|
|
+ //方法二end
|
|
|
+
|
|
|
+ $wx_data["acsMerNo"] = HAO_YI_LIAN_ACS_MER_NO;//业务商户号
|
|
|
+ $wx_data["fileName"] = '20210506114611';//文件名称
|
|
|
+ $wx_data["fileType"] = 'jpg';//文件类型
|
|
|
+ // $wx_data["md5Code"] = hash_file('md5',$path);
|
|
|
+ $wx_data["md5Code"] = md5_file($path);
|
|
|
+ $wx_data["fileData"] = $bytes;//文件转换成byte数组
|
|
|
+
|
|
|
+ // $wx_data .='&';
|
|
|
+ $haoYiLian = Lib_Haoyilian_Haoyilian::init();
|
|
|
+ $wx_order = $haoYiLian->apiRequest("gnete.psbc.electronic.PsbcFile", "upload", $wx_data);
|
|
|
+ dump($wx_order);
|
|
|
+}
|