Php 如何在jquery中一次性发布多个base64字符串

Php 如何在jquery中一次性发布多个base64字符串,php,jquery,image,base64,Php,Jquery,Image,Base64,我在我的网站[Ref:]中使用了奇特的产品设计器工具。我需要通过jquery post方法使用base64转换将多个图像保存到本地文件夹中。但在我的代码中只保存一个图像 我的Html和Jquery代码: <a href="#inline_content2" id="save-image-php" class="inline" >Approve</a> <script type="text/javascript"> $('#save-image-php').

我在我的网站[Ref:]中使用了奇特的产品设计器工具。我需要通过jquery post方法使用base64转换将多个图像保存到本地文件夹中。但在我的代码中只保存一个图像

我的Html和Jquery代码:

<a href="#inline_content2" id="save-image-php" class="inline" >Approve</a>


<script type="text/javascript">
$('#save-image-php').click(function() {

                yourDesigner.getProductDataURL(function(dataURL) {
                     alert(dataURL);
                    $.post( "php/save_image.php", { base64_image: dataURL} );
                    return;
                });

            });

</script>

$(“#保存图像php”)。单击(函数(){
yourDesigner.getProductDataURL(函数(dataURL){
警报(数据URL);
$.post(“php/save_image.php”,{base64_image:dataURL});
返回;
});
});
save_image.php

<?php
require "../includes/config.php";

/*
*
* An example php that gets the 64 bit encoded PNG URL and creates an image of it
*
*/

//get the base-64 from data
$base64_str = substr($_POST['base64_image'], strpos($_POST['base64_image'], ",")+1);


//decode base64 string
$decoded = base64_decode($base64_str);

$png_url ="../uploads/products/design/"."product-".strtotime('now').".png";
$image_name ="product-".strtotime('now').".png";

//create png from decoded base 64 string and save the image in the parent folder



$update=mysqli_query($conn,"update tbl_session set image='$image_name' where prod_id='".$_SESSION['ses_prod']."' and ses_id='".$session_id."'");

$result = file_put_contents($png_url, $decoded);

//send result - the url of the png or 0
header('Content-Type: application/json');
if($result) {
    $png_url = get_folder_url().$png_url;
    echo json_encode($png_url);
}
else {
    echo json_encode(0);
}

//returns the current folder URL
function get_folder_url() {
    $url = $_SERVER['REQUEST_URI']; //returns the current URL
    $parts = explode('/',$url);
    $dir = $_SERVER['SERVER_NAME'];
    for ($i = 0; $i < count($parts) - 1; $i++) {
        $dir .= $parts[$i] . "/";
    }
    return 'http://'.$dir;
}

?>


现在我的问题是如何使用jquery将base64字符串数组发布到php文件中。提前谢谢。

你们都找到解决方案了吗?