My AJAX request always sends the same data. How can I use the convertImgToBase64
function without this issue?
$imageMaps[0] = '1.jpeg';
$imageMaps[1] = '2.jpeg';
for (var k in $imageMaps) {
$file = $imageMaps[k]
convertImgToBase64($url, function(base64Img) {
$file = $imageMaps[k]
$.ajax({
type: "POST",
async: 0,
beforeSend: function(xhr, settings) {},
url: '/request.php?imagePost=1',
data: {
file: $file,
data: base64Img
},
processData: 1,
cache: 1,
xhr: function() {},
success: function(){}
});
}
})
request.php
<?php
echo $_POST['file']; //output always "2.jpeg"
?>
Now i got it. Only problem now is the base64 encoding returning String, which doesnt return the Value.