wupengfei 2 年之前
父節點
當前提交
b383194413
共有 3 個文件被更改,包括 21 次插入1 次删除
  1. 1 0
      .idea/workspace.xml
  2. 1 1
      application/api/controller/Upload.php
  3. 19 0
      application/common.php

+ 1 - 0
.idea/workspace.xml

@@ -3,6 +3,7 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/controller/Upload.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Upload.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />

+ 1 - 1
application/api/controller/Upload.php

@@ -96,7 +96,7 @@ class Upload extends Base
         var_dump($file->getInfo()['name']);
         $headers = [];
         $headers[] = 'Content-Type: application/x-www-form-urlencoded';
-        $res = requestPost('http://101.132.128.55:9999/v1/pdf/upload',['file'=>$file->getInfo()['name']],$headers);
+        $res = pdfCurl($file->getInfo()['name']);
         var_dump($res);
 
 

+ 19 - 0
application/common.php

@@ -339,6 +339,25 @@ function http_post_json($url, $jsonStr,$token_res)
     return  json_decode($response,true);
 }
 
+function pdfCurl($file_name)
+{
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_URL, 'http://101.132.128.55:9999/v1/pdf/upload');
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_POST, 1);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, "file=@$file_name");
+    $headers = array();
+    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+    $result = curl_exec($ch);
+    if (curl_errno($ch)) {
+        echo 'Error:' . curl_error($ch);
+    }
+    curl_close($ch);
+    return $result;
+}
+
+
 
 function getVideoTime($ali_id)
 {