Bonjour a tous,
je rencontre un soucis lors d'un envoi en CURL d'un site 1 vers un un site 2 , d'un fichier .tar.
Plus précisément lors du
Code : Sélectionner tout - Visualiser dans une fenêtre à part
file_put_contents(__DIR__.'/recups/'.$resp->name, $filebin);
je reçois bien mon fichier mais sa création dans le répertoire de destination est endommagé

code envoi :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$archive = new PharData($nameZip);
$archive->buildFromDirectory($pathZip);
 
 
$data=array(
  'name' => $nameZip,
  'file' => base64_encode(file_get_contents($path))
);
 
$ch = curl_init();
$options = array(
  CURLOPT_URL => 'https://monUrl/monFichier.php?pkey=xxxxxxxx',
  CURLOPT_RETURNTRANSFER => true,
  CURLINFO_HEADER_OUT => true, //Request header
  CURLOPT_HEADER => true, //Return header
  CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
  CURLOPT_SSL_VERIFYPEER => false, //Don't veryify server certificate
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data)
);
 
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$header_info = curl_getinfo($ch,CURLINFO_HEADER_OUT);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $header_size);
$body = substr($result, $header_size);
curl_close($ch);

code réception :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
$body = file_get_contents('php://input');
 
$resp = json_decode($body);
 
$filebin = base64_decode($resp->file);
 
 
file_put_contents(__DIR__.'/recups/'.$resp->name, $filebin);
Merci à vous