Пример #1
0
//                     'product_subtypes'=> $subtypes,
//                     'product_surface_types'=> $surface_types,
//                     'product_colors'=> $colors,
//                     'product_features'=> $features
//                   );
//         }
//     }
//     $app->response()->header('content-type','application/json');
//     echo json_encode(array('product_data'=>$data));
// });
// --------------------------------------
// Image download from url still have to work on it later.
$app->get('/shiningfloor/downloadImage', function () use($app, $db) {
    foreach ($db->products as $p) {
        if ($p['id'] <= 5005) {
            $filenameIn = $db->product_images()->where('products_id', $p['id'])->fetch()['image_name'];
            $filenameOut = '../uploads/products/' + $p['id'] + '_1.jpg';
            $ch = curl_init($filenameIn);
            $fp = fopen($filenameOut, 'wb');
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_exec($ch);
            curl_close($ch);
            fclose($fp);
            // // print_r($filenameIn);
            // // print_r($filenameOut);
            // $contentOrFalseOnFailure   = file_get_contents($filenameIn);
            // //Store in the filesystem.
            // $fp = fopen('../uploads/products/'+$p['id']+'_1.jpg', "w");
            // fwrite($fp, $contentOrFalseOnFailure);
            // fclose($fp);