diff --git a/Service.php b/Service.php index ecfd3f47439c2f67a2e3462543c561c030db6c99..9a6e34f6c64d460eaa32e6184399d47427ff5d87 100644 --- a/Service.php +++ b/Service.php @@ -59,7 +59,9 @@ if (isset($decoded['images'])){ $nom = strtr( $nom, $accents ); foreach (array_filter(glob('Photos/*.jpg'), 'is_file') as $file){ if ('Photos/'.$nom.'.jpg' == $file){ - echo '<img src="data:image/jpg;base64,'.base64_encode(file_get_contents($file)).'">'; + echo $file; + }else{ + echo ''; } } unset($decoded['images']); diff --git a/suggestion.js b/suggestion.js index 3520c0520bda5253c26645b4f41a9a9d42c94a94..1913139c37550b5f0f36025ffa0854eae53d0eb7 100644 --- a/suggestion.js +++ b/suggestion.js @@ -43,9 +43,23 @@ function afficheRecettes(recette){ } const search = recette[i].titre; + const input = { images : search }; + + + var xhr = new XMLHttpRequest(); + + xhr.open('POST', "Service.php", true); + + xhr.onload = () => { + if (xhr.response != null){ + image.src = xhr.responseText; + } + }; + + xhr.send(JSON.stringify(input)); // Ajout à la div de recettes div.append(titre);