Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否有可靠的方法将记录存储在服务器1中,并将记录的映像存储在服务器2中_Php_Mysql - Fatal编程技术网

Php 是否有可靠的方法将记录存储在服务器1中,并将记录的映像存储在服务器2中

Php 是否有可靠的方法将记录存储在服务器1中,并将记录的映像存储在服务器2中,php,mysql,Php,Mysql,在我的android应用程序中,我需要将一条记录发送到我的“php服务器”,并将该记录的图像保存到另一个“文件服务器”。这两项工作都需要像交易一样同时进行 我可以将所有数据(文本和图像)发送到“php服务器”。然后保存记录,然后将图像发送到“文件服务器”。但我的“php服务器”有带宽限制 另一种方法是将所有数据(文本和图像)发送到文件服务器(我的文件服务器支持php脚本),然后将文本发送到“php服务器”,然后在获得成功结果后将图像保存到磁盘。 我是php新手,我想问有没有更好的方法来实现这一

在我的android应用程序中,我需要将一条记录发送到我的“php服务器”,并将该记录的图像保存到另一个“文件服务器”。这两项工作都需要像交易一样同时进行

我可以将所有数据(文本和图像)发送到“php服务器”。然后保存记录,然后将图像发送到“文件服务器”。但我的“php服务器”有带宽限制

另一种方法是将所有数据(文本和图像)发送到文件服务器(我的文件服务器支持php脚本),然后将文本发送到“php服务器”,然后在获得成功结果后将图像保存到磁盘。

我是php新手,我想问有没有更好的方法来实现这一点?

现在我用这种方法 我在文件服务器中的当前代码是:

$data = array(
    'tag' => "createProduct",
    'token' => "$token",
    'shop_uid' => $shop_uid,
    'image1' => $image1_name,
    'image2' => $image2_name,
    'image3' => $image3_name,
    'image4' => $image4_name,
    'image5' => $image5_name,
    'name' => $name,
    'description' => $description
);
# Create a connection
$url = 'http://myhost.com/myproject/function.php';
$ch = curl_init($url);
# Form data string
$postString = http_build_query($data, '', '&');
# Setting our options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
# Get the response
$response = curl_exec($ch);
curl_close($ch);

if ($response == null) {
    // failed
    echo "{\"result\":0,\"messageCode\":19}";
} else {
    // save images
    if ($image1 != "") storeProductImage($image1_name, $image1);
    if ($image2 != "") storeProductImage($image2_name, $image2);
    if ($image3 != "") storeProductImage($image3_name, $image3);
    if ($image4 != "") storeProductImage($image4_name, $image4);
    if ($image5 != "") storeProductImage($image5_name, $image5);

    // send ok result to client
    echo $response;

}