This repository was archived by the owner on Mar 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,31 @@ public function curlProcess()
8282 curl_close ($ ch );
8383 }
8484
85+ /**
86+ * PHP5.6은 CURLOPT_SAFE_UPLOAD를 설정하지 않으면 이미지 path로 보내는게 작동하지 않으며
87+ * PHP7에서 완전히 제거, 따라서 PHP5.6이상은 CurlFile개체를 사용하여 이미지 데이터 반환
88+ * https://wiki.php.net/rfc/curl-file-upload 참고
89+ */
90+ private function getImageData ($ filename )
91+ {
92+ $ file = pathinfo ($ filename );
93+ $ contentType = "iamge/ {$ file ['extension ' ]}" ;
94+ $ postname = $ file ['basename ' ];
95+
96+ // PHP5.6이상
97+ if (function_exists ('curl_file_create ' )) {
98+ return curl_file_create ($ filename , $ contentType , $ postname );
99+ }
100+
101+ // PHP5.6이하
102+ $ value = "@ {$ filename };filename= " . $ postname ;
103+ if ($ contentType ) {
104+ $ value .= ';type= ' . $ contentType ;
105+ }
106+
107+ return $ value ;
108+ }
109+
85110 /**
86111 * set http body content
87112 */
@@ -95,7 +120,7 @@ private function setContent($options)
95120 if ($ key != "image " )
96121 $ this ->content [$ key ] = sprintf ("\0%s " , $ val );
97122 else
98- $ this ->content [$ key ] = ' @ ' . realpath (" $ val" );
123+ $ this ->content [$ key ] = $ this -> getImageData ( realpath ($ val) );
99124 }
100125 }
101126 else
Original file line number Diff line number Diff line change 3535// $options->template_code = '#ENTER_YOUR_TEMPLATE_CODE#';
3636
3737// Optional parameters for your own needs
38- // $options->image = 'desert.jpg '; // image for MMS. type must be set as 'MMS'
38+ // $options->image = 'test.png '; // image for MMS. type must be set as 'MMS'
3939// $options->refname = ''; // Reference name
4040// $options->country = 'KR'; // Korea(KR) Japan(JP) America(USA) China(CN) Default is Korea
4141// $options->datetime = '20140106153000'; // Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00)
You can’t perform that action at this time.
0 commit comments