teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

自己解決コードの記述

2016/09/06 06:51

投稿

tarotarosu
tarotarosu

スコア114

title CHANGED
File without changes
body CHANGED
@@ -76,4 +76,33 @@
76
76
 
77
77
  ----------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
78
78
  Content-Disposition: form-data; name="sendData"; filename="sendData.xml"
79
- Content-Type: text/xml
79
+ Content-Type: text/xml
80
+
81
+ ###追記2
82
+ 下記のように記述したところ無事解決しました。
83
+ ご回答ありがとうございました_(._.)_
84
+
85
+ ```php
86
+ $url = "送り先";
87
+
88
+ $boundary = "---------------------".substr(md5(rand(0,32000)), 0, 10);
89
+ $boundaryMod = "--" .$boundary;
90
+ $xmlData = file_get_contents("data.xml");
91
+ $postdata = "";
92
+
93
+ $postdata .= "$boundaryMod\n";
94
+ $postdata .= 'Content-Disposition: form-data; name="sendData"; filename="data.xml"' ."\n";
95
+ $postdata .= 'Content-Type: text/xml' ."\n\n";
96
+ $postdata .= $xmlData . "\n";
97
+ $postdata .= "\n" .$boundaryMod. "--" ."\n";
98
+
99
+ $ch = curl_init($url);
100
+ curl_setopt($ch, CURLOPT_POST, true);
101
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
102
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data; boundary=' .$boundary. ' ', 'Cache-Control: no-store,no-cache', 'Accept: text/*', 'Paragma: no-cache'));
103
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
104
+ $result = curl_exec($ch);
105
+ curl_close($ch);
106
+
107
+ echo $result;
108
+ ```

1

追記の記述

2016/09/06 06:51

投稿

tarotarosu
tarotarosu

スコア114

title CHANGED
File without changes
body CHANGED
@@ -69,4 +69,11 @@
69
69
  throw error;
70
70
  }
71
71
  }
72
- ```
72
+ ```
73
+
74
+ ###追記
75
+ おそらく、このような情報が付与できれば良いとは思うのですが、どのようにしてよいのか…
76
+
77
+ ----------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
78
+ Content-Disposition: form-data; name="sendData"; filename="sendData.xml"
79
+ Content-Type: text/xml