0

JSON Web サービス経由で画像を送信する方法はありますか?

これは、特定のフォルダーで新しい画像を検索し、(パス、画像ファイルの名前である id とファイルの作成時刻) を含むいくつかのデータを返す私のコードです。

function getAllNewPhotos($lastCHK) {

    $dirPath = 'c:\my_images';
    $files1 = scandir($dirPath);
    $files = array_diff($files1, array('.', '..'));
    $newFiles = array();
    foreach ($files as $file) {
        $createTime = filectime($dirPath . '/' . $file);
        $path_data = pathinfo($dirPath . '/' . $file);          
                if ($createTime > $lastCHK) {
                    $newFiles[] = array(
                        'path' => $dirPath . '\\' . $file,                            
                        'ID' => $path_data['filename'],         
                        'dateImagAdded' => date('Y-m-d H:i:s', $createTime),
                    );
                }

    }
    return ($newFiles);
}

すでに渡した他のデータと一緒に実際の画像を送信する方法はありますか?

さらに明確にする必要がある場合は、さらに明確にする必要がある部分をお知らせください。

ありがとう

4

1 に答える 1

0

base64 を使用して画像をエンコードできます

$imagedata = file_get_contents("/path/to/image.jpg");
             // alternatively specify an URL, if PHP settings allow
$base64 = base64_encode($imagedata);
于 2014-10-08T12:07:56.157 に答える