PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/Telegram/FilesApiHelper.php +43 -19 3.2.22.15.3 View file →
@@ -6,10 +6,8 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\Telegram;
9 9
10 -use BitCode\BitForm\Core\Util\FileHandler;
11 -
12 10 /**
13 11 * Provide functionality for Upload files
14 12 */
15 13 final class FilesApiHelper
@@ -26,9 +24,9 @@
26 24 public function __construct($formID, $entryID)
27 25 {
28 26 $this->_payloadBoundary = wp_generate_password(24);
29 27 $this->_defaultHeader['Content-Type'] = 'multipart/form-data; boundary=' . $this->_payloadBoundary;
30 - $this->_basepath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR;
28 + $this->_basepath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR;
31 29 }
32 30
33 31 /**
34 32 * Helps to execute upload files api
@@ -70,15 +68,28 @@
70 68 $data[$param] = new \CURLFILE($filePath);
71 69 if ('photo' !== $param) {
72 70 unset($data['photo']);
73 71 }
74 - $args = [
75 - 'body' => $data,
76 - 'timeout' => 30,
77 - 'headers' => $this->_defaultHeader,
78 - ];
79 - $response = wp_remote_post($uploadFileEndpoint, $args);
80 - return wp_remote_retrieve_body($response);
72 + $curl = curl_init();
73 + curl_setopt_array(
74 + $curl,
75 + [
76 + CURLOPT_URL => $uploadFileEndpoint,
77 + CURLOPT_RETURNTRANSFER => true,
78 + CURLOPT_ENCODING => '',
79 + CURLOPT_MAXREDIRS => 10,
80 + CURLOPT_TIMEOUT => 0,
81 + CURLOPT_FOLLOWLOCATION => true,
82 + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
83 + CURLOPT_CUSTOMREQUEST => 'POST',
84 + CURLOPT_POSTFIELDS => $data,
85 + ]
86 + );
87 +
88 + $uploadResponse = curl_exec($curl);
89 +
90 + curl_close($curl);
91 + return $uploadResponse;
81 92 }
82 93
83 94 public function uploadMultipleFiles($apiEndPoint, $data)
84 95 {
@@ -120,17 +131,30 @@
120 131 if ('media' !== $param) {
121 132 unset($data['media']);
122 133 }
123 134
124 - $args = [
125 - 'body' => $postFields,
126 - 'timeout' => 30,
127 - 'headers' => [
128 - 'Content-Type' => 'multipart/form-data'
129 - ],
130 - ];
131 - $response = wp_remote_post($uploadMultipleFileEndpoint, $args);
132 - return wp_remote_retrieve_body($response);
135 + $curl = curl_init();
136 + curl_setopt_array(
137 + $curl,
138 + [
139 + CURLOPT_URL => $uploadMultipleFileEndpoint,
140 + CURLOPT_RETURNTRANSFER => true,
141 + CURLOPT_ENCODING => '',
142 + CURLOPT_MAXREDIRS => 10,
143 + CURLOPT_TIMEOUT => 0,
144 + CURLOPT_FOLLOWLOCATION => true,
145 + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
146 + CURLOPT_CUSTOMREQUEST => 'POST',
147 + CURLOPT_POSTFIELDS => $postFields,
148 + CURLOPT_HTTPHEADER => [
149 + 'Content-Type: multipart/form-data'
150 + ],
151 + ]
152 + );
153 +
154 + $uploadResponse = curl_exec($curl);
155 + curl_close($curl);
156 + return $uploadResponse;
133 157 }
134 158
135 159 private function getFileNameWithExtension($url)
136 160 {