<?php
include("src/Dealhot.php");
include("config.php");

$msg = 'Upload a photo for the deal';
$titleHeader = "Deal photo";

if(@$_POST["submit"]=="Upload"){	
  $action = 'photo_upload';
  $photo_index = $_POST["photo_index"];
  $id = $_POST["id"];
  $pDate = $_POST["pDate"];
  
  $tmpfile = $_FILES['picture'.$photo_index]['tmp_name'];
  $filename = $_FILES['picture'.$photo_index]['name'];
      
  $rest_data = array(
   'file'=>'@'.$tmpfile,
   'name'=> $filename,
   'productID'=>$id,
   'photo_index'=>$photo_index,
   'pDate'=>$pDate
  );
      
  $Dealhot = new Dealhot($auth_arr,$action,$rest_data);
  $result_arr = $Dealhot->upload();
  
  if($result_arr["result"]=="success")
    $msg = 'You have uploaded the photo successfully. '.$result_arr["msg"];
  else if($result_arr["result"]=="fail")
    $msg = 'You have failed to upload the photo. Reason: '.$result_arr["error"];
}
?>