public function store(ValidateUploadAttraction $request)
 {
     $attraction = new ParseObject("attractions");
     $attraction->set("name", $request->get('name'));
     $attraction->set("type", $request->get('type'));
     $attraction->set("location", $request->get('location'));
     $attraction->set("description", $request->get('description'));
     $file = $request->file('image');
     // $localFilePath = "/public/images/attractions/Palace.jpg";
     $f = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $_FILES['image']['name']);
     $f->save();
     $audio = $request->file('media');
     $m = ParseFile::createFromData(file_get_contents($_FILES['media']['tmp_name']), $_FILES['media']['name']);
     $m->save();
     $attraction->set("image", $f);
     $attraction->set("media", $m);
     $a = $request->get('priority');
     $int = (int) $a;
     $attraction->set("priority", $int);
     $expID = 'wJacAzyx3T';
     $exp = '7YuChBta6I';
     $query = new ParseQuery("experts");
     $expertID = $query->get($expID);
     $query1 = new ParseQuery("Cities");
     $expert = $query1->get($exp);
     $attraction->set("expert", $expertID);
     $attraction->set("city_attractions", $expert);
     $attraction->save();
     return \Redirect::route('uploadAttractions')->with('message', 'Attraction has been created');
 }
 public function upload(Request $request)
 {
     if (isset($_FILES['image'])) {
         // save file to Parse
         try {
             $fname = str_replace(' ', '', $_FILES['image']['name']);
             $file = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $fname);
             $file->save();
             // save something to class TestObject
             $asset = new ParseObject("Assets");
             // add the file we saved above
             $asset->set("file", $file);
             $asset->save();
             $ret = ['status' => 'success', 'data' => ['asset' => ['id' => $asset->getObjectId()], 'file' => ['url' => $file->getUrl()]]];
             return response()->json($ret);
         } catch (ParseException $ex) {
             $ret = ['status' => 'fail', 'error' => $ex->getMessage()];
             return response()->json($ret);
         }
     } else {
         $ret = ['status' => 'fail', 'error' => 'no file selected'];
         return response()->json($ret);
     }
 }
Example #3
0
     } elseif (!in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats)) {
         $message[] = "{$name} is not a valid format";
         continue;
         // Skip invalid file formats
     } else {
         // No error found! Move uploaded files
         $parts = explode(".", $name);
         $query = new ParseQuery("Photos");
         $query->equalTo("FileName", $parts[0]);
         $results = $query->find();
         if (count($results) == 0) {
             if (move_uploaded_file($_FILES['files']['tmp_name'][$f], "uploads/" . $name)) {
                 $file = fopen("uploads/" . $name, "rb");
                 $contents = fread($file, filesize("uploads/" . $name));
                 fclose($file);
                 $fileImage = ParseFile::createFromData($contents, $name);
                 $fileImage->save();
                 $parts = explode(".", $name);
                 $images = new ParseObject("Photos");
                 $images->set("FileName", (int) $parts[0]);
                 $images->set("FileImage", $fileImage);
                 try {
                     $images->save();
                 } catch (ParseException $ex) {
                     echo 'There is a problem!: ' . $ex->getMessage();
                 }
             }
         }
     }
 }
 $count++;
Example #4
0
 public function testFileDelete()
 {
     $data = "c-c-c-combo breaker";
     $name = "php.txt";
     $file = ParseFile::createFromData($data, $name);
     $file->save();
     $url = $file->getURL();
     $fileAgain = ParseFile::_createFromServer($name, $url);
     $contents = $fileAgain->getData();
     $this->assertEquals($data, $contents);
     $file->delete();
     $fileAgain = ParseFile::_createFromServer($name, $url);
     $this->setExpectedException('Parse\\ParseException', 'Download failed');
     $contents = $fileAgain->getData();
 }
Example #5
0
 public function do_update(array $params = [])
 {
     $mark = array();
     for ($x = 0; $x < count($_POST['title']); $x++) {
         $tag = new ParseObject("BrandTag");
         $tag->set("xCoordinate", (double) $_POST['x'][$x]);
         $tag->set("yCoordinate", (double) $_POST['y'][$x]);
         $tag->set("tagName", $_POST['title'][$x]);
         $tag->save();
         $query = new ParseQuery("BrandTag");
         $query->descending("createdAt");
         $object = $query->first();
         $idq = $object->getObjectId();
         $mark[] = array('__type' => 'Pointer', 'className' => 'BrandTag', 'objectId' => '' . $idq . '');
     }
     $brandName = $_POST['brandName'];
     $id = $_POST['id'];
     $query = new ParseQuery("BrandPost");
     $query->equalTo("objectId", $id);
     $question = $query->first();
     $question->setArray("tagArray", $mark);
     $question->set("brandName", $brandName);
     $question->set("content", $_POST['content']);
     if (isset($_POST['items'])) {
         $it = array();
         foreach ($_POST['items'] as $item) {
             $it[] = array('__type' => 'Pointer', 'className' => 'BrandItem', 'objectId' => '' . $item . '');
             $question->setArray("brandItems", $it);
         }
     }
     if (isset($_FILES['image']) && !empty($_FILES['image'])) {
         if (($_FILES["image"]["type"] == "image/png" || $_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/jpeg") && $_FILES["image"]["size"] < 10000000) {
             $size = getimagesize($_FILES['image']['tmp_name']);
             $file = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $_FILES['image']['name']);
             $file->save();
             $question->set("postImage", $file);
         }
     }
     $question->save();
     redirect(ADMIN_URL . 'brand_post');
     $this->template = false;
 }
Example #6
0
    $coupon->set("brand", $brand);
    $coupon->set("title", $_POST['coupon_title']);
    $coupon->set("brandName", $brand->get("name"));
    $coupon->set("type", $_POST['coupon_type']);
    if ($_POST['coupon_type'] == "Public") {
        $coupon->set("isFirstUpdate", true);
    } else {
        $coupon->set("isFirstUpdate", false);
    }
    $coupon->set("currentUsage", 0);
    $coupon->set("maxUsage", intval($_POST['coupon_max_usage']));
    $startDateTime = new DateTime($_POST['coupon_start_datetime']);
    $coupon->set("startDateTime", $startDateTime);
    $endDateTime = new DateTime($_POST['coupon_end_datetime']);
    $coupon->set("endDateTime", $endDateTime);
    $file = ParseFile::createFromData(file_get_contents($_FILES['coupon_image']['tmp_name']), $_FILES['coupon_image']['name']);
    $file->save();
    $coupon->set("file", $file);
    $coupon->set("visitThreshold", intval($_POST['coupon_visit_threshold']));
    $coupon->save();
    $post_message = "COUPON SAVED";
    //    exit;
}
?>
    <!DOCTYPE html>
    <html lang="en">

    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
 public function order()
 {
     $currentUser = ParseUser::getCurrentUser();
     if ($currentUser) {
         // do stuff with the user
     } else {
         // show the signup or login page
         Url::redirect('login');
     }
     if (isset($_POST['table'])) {
         View::render('inventory/order-table', $data, $error);
     } elseif (isset($_POST['del']) && isset($_POST['objectId'])) {
         $objectId = $_POST['objectId'];
         $query = new ParseQuery('Order');
         try {
             $data = 1;
         } catch (ParseException $ex) {
             $data = $ex;
         }
         $query->equalTo('objectId', $objectId);
         $order = $query->first();
         $order->destroy();
         header('Content-type: application/json; charset=utf-8');
         echo json_encode(array('result' => $data));
     } elseif (isset($_POST['update'])) {
         $objectId = !isset($_POST['objectId']) || trim($_POST['objectId']) == '' ? '' : $_POST['objectId'];
         $productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId'];
         $productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
         $customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId'];
         $customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName'];
         $lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId'];
         $facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook'];
         $telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone'];
         $transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']);
         $address = !isset($_POST['address']) || trim($_POST['address']) == '' ? '' : $_POST['address'];
         $transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus'];
         $transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus'];
         $trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber'];
         $contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook];
         if ($_FILES['fileToUpload']['size'] > 0) {
             $target_file = basename($_FILES["fileToUpload"]["name"]);
             $uploadOk = 1;
             $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 //echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 //echo "File is not an image.";
                 $uploadOk = 0;
             }
             // Check file size
             if ($_FILES["fileToUpload"]["size"] > 500000) {
                 $error = "Sorry, your file is too large." . $error;
                 $uploadOk = 0;
             }
             // Allow certain file formats
             if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                 $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
                 $uploadOk = 0;
             }
             // Check if $uploadOk is set to 0 by an error
             if ($uploadOk == 0) {
                 $error = "Sorry, your file was not uploaded." . $error;
                 // if everything is ok, try to upload file
             } else {
                 $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
                 $query = new ParseQuery('Order');
                 $query->equalTo('objectId', $objectId);
                 $order = $query->first();
                 $order->set('productId', $productId);
                 $order->set('productName', $productName);
                 $order->set('customerName', $customerName);
                 $order->set('customerId', $customerId);
                 $order->setAssociativeArray('contact', $contact);
                 $order->set('slipPayin', $imageFile);
                 $order->set('transportDate', $transportDate);
                 $order->set('address', $address);
                 $order->set('transportStatus', $transportStatus);
                 $order->set('transferStatus', $transferStatus);
                 $order->set('trackingNumber', $trackingNumber);
                 $order->save();
             }
         } else {
             $query = new ParseQuery('Order');
             $query->equalTo('objectId', $objectId);
             $order = $query->first();
             $order->set('productId', $productId);
             $order->set('productName', $productName);
             $order->set('customerName', $customerName);
             $order->set('customerId', $customerId);
             $order->setAssociativeArray('contact', $contact);
             $order->set('transportDate', $transportDate);
             $order->set('address', $address);
             $order->set('transportStatus', $transportStatus);
             $order->set('transferStatus', $transferStatus);
             $order->set('trackingNumber', $trackingNumber);
             $order->save();
         }
     } else {
         if (isset($_POST['submit'])) {
             $productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId'];
             $productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
             $customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId'];
             $customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName'];
             $lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId'];
             $facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook'];
             $telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone'];
             $transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']);
             $transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus'];
             $transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus'];
             $trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber'];
             $contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook];
             if ($_FILES['fileToUpload']['size'] > 0) {
                 $target_file = basename($_FILES["fileToUpload"]["name"]);
                 $uploadOk = 1;
                 $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
                 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
                 if ($check !== false) {
                     //echo "File is an image - " . $check["mime"] . ".";
                     $uploadOk = 1;
                 } else {
                     //echo "File is not an image.";
                     $uploadOk = 0;
                 }
                 // Check file size
                 if ($_FILES["fileToUpload"]["size"] > 500000) {
                     $error = "Sorry, your file is too large." . $error;
                     $uploadOk = 0;
                 }
                 // Allow certain file formats
                 if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                     $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
                     $uploadOk = 0;
                 }
                 // Check if $uploadOk is set to 0 by an error
                 if ($uploadOk == 0) {
                     $error = "Sorry, your file was not uploaded." . $error;
                     // if everything is ok, try to upload file
                 } else {
                     $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
                     $order = new ParseObject('Order');
                     $order->set('productId', $productId);
                     $order->set('productName', $productName);
                     $order->set('customerName', $customerName);
                     $order->set('customerId', $customerId);
                     $order->setAssociativeArray('contact', $contact);
                     $order->set('slipPayin', $imageFile);
                     $order->set('transportDate', $transportDate);
                     $order->set('address', $address);
                     $order->set('transportStatus', $transportStatus);
                     $order->set('transferStatus', $transferStatus);
                     $order->set('trackingNumber', $trackingNumber);
                     $order->save();
                 }
             } else {
                 $order = new ParseObject('Order');
                 $order->set('productId', $productId);
                 $order->set('productName', $productName);
                 $order->set('customerName', $customerName);
                 $order->set('customerId', $customerId);
                 $order->setAssociativeArray('contact', $contact);
                 $order->set('transportDate', $transportDate);
                 $order->set('address', $address);
                 $order->set('transportStatus', $transportStatus);
                 $order->set('transferStatus', $transferStatus);
                 $order->set('trackingNumber', $trackingNumber);
                 $order->save();
             }
             Url::redirect('order');
         }
         $sidemenu = new ParseQuery('SideMenu');
         $result = $sidemenu->find();
         Hooks::addHook('js', 'Controllers\\inventory\\Order@JS');
         Hooks::addHook('css', 'Controllers\\inventory\\Order@CSS');
         $data['title'] = 'รายการสั่งซื้อสินค้า';
         $data['username'] = $currentUser->get('username');
         $data['sidemenu'] = $result;
         View::rendertemplate('header', $data);
         View::render('inventory/order', $data, $error);
         View::rendertemplate('footer', $data);
     }
 }
Example #8
0
 public function testFileDelete()
 {
     $data = 'c-c-c-combo breaker';
     $name = 'php.txt';
     $file = ParseFile::createFromData($data, $name);
     $file->save();
     $url = $file->getURL();
     $fileAgain = ParseFile::_createFromServer($name, $url);
     $contents = $fileAgain->getData();
     $this->assertEquals($data, $contents);
     $file->delete();
     //We can't retrieve deleted file because it cached with CloudFront.
     //We need to check it's availability throw Parse API (?) or
     //turn on CloudFront's cache invalidation based on query string
     //$fileAgain = ParseFile::_createFromServer($name, $url);
     //$this->setExpectedException('Parse\ParseException', 'Download failed');
     //$contents = $fileAgain->getData();
 }
Example #9
0
     break;
 case 'getEmployee':
     $employee = new ParseQuery("Employers");
     $employee->limit(1000);
     $employee->equalTo("objectId", $_GET['objectId']);
     $results = $employee->find();
     $returnData = json_encode(array("success" => true, "data" => $results));
     break;
 case 'gallery':
     $gallery = new ParseQuery("gallery");
     $gallery->limit(1000);
     $results = $gallery->find();
     $returnData = json_encode(array("success" => true, "data" => $results));
     break;
 case 'uploadFile':
     $file = ParseFile::createFromData(file_get_contents("php://input"), str_replace(" ", "", $_REQUEST['name']));
     $file->save();
     $url = $file->getURL();
     $name = $file->getName();
     $returnData = '{"name":"' . $name . '","url":"' . $url . '"}';
     break;
 case 'uploadFileImg':
     $file = ParseFile::createFromFile($_FILES['pic']['tmp_name'], str_replace(" ", "", $_FILES['pic']['name']));
     $file->save();
     $url = $file->getURL();
     $name = $file->getName();
     echo '{"name":"' . $name . '","url":"' . $url . '"}';
     exit;
     break;
 case 'updateEmployee':
     $dataObject = json_decode(file_get_contents("php://input"), true);
Example #10
0
<?php
require 'vendor/autoload.php';
 
use Parse\ParseClient;
 
ParseClient::initialize('KFNVzk7T8kVDWwzid200j9Yd2DonVQa7bcgXoNg2', 'LgTcbJTbUzaFkEdb4gXv5q6Ja9FaUUqTH05eG0sF', 'JPtos4hBuaVKmlbbLsPc4q6psGybfgiYIiFzS0dH');
 use Parse\ParseFile;
   $contents = $_POST["content"];
   $title = $_POST["title"];
   $file = ParseFile::createFromData($contents, $title.".html");
   
   ?>
Example #11
0
 public function testUnsavedFileOnObjectSave()
 {
     $contents = "remember";
     $file = ParseFile::createFromData($contents, "bones.txt");
     $obj = ParseObject::create("TestFileObject");
     $obj->set("file", $file);
     $obj->save();
     $query = new ParseQuery("TestFileObject");
     $objAgain = $query->get($obj->getObjectId());
     $fileAgain = $objAgain->get("file");
     $contentsAgain = $fileAgain->getData();
     $this->assertEquals($contents, $contentsAgain);
 }
 public function product()
 {
     // if(!Session::get('loggedin')){
     //     Url::redirect('login');
     // }
     $currentUser = ParseUser::getCurrentUser();
     if ($currentUser) {
         // do stuff with the user
     } else {
         // show the signup or login page
         Url::redirect('login');
     }
     if (isset($_POST['table'])) {
         View::render('inventory/product-table', $data, $error);
     } elseif (isset($_POST['del']) && isset($_POST['objectId'])) {
         $objectId = $_POST['objectId'];
         $query = new ParseQuery('Product');
         try {
             $data = 1;
         } catch (ParseException $ex) {
             $data = $ex;
         }
         $query->equalTo('objectId', $objectId);
         $product = $query->first();
         $product->destroy();
         header('Content-type: application/json; charset=utf-8');
         echo json_encode(array('result' => $data));
     } elseif (isset($_POST['update'])) {
         $objectId = !isset($_POST['objectId']) || trim($_POST['objectId']) == '' ? '' : $_POST['objectId'];
         $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
         $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']);
         $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription'];
         if ($_FILES['fileToUpload']['size'] > 0) {
             $target_file = basename($_FILES["fileToUpload"]["name"]);
             $uploadOk = 1;
             $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 //echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 //echo "File is not an image.";
                 $uploadOk = 0;
             }
             // Check file size
             if ($_FILES["fileToUpload"]["size"] > 500000) {
                 $error = "Sorry, your file is too large." . $error;
                 $uploadOk = 0;
             }
             // Allow certain file formats
             if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                 $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
                 $uploadOk = 0;
             }
             // Check if $uploadOk is set to 0 by an error
             if ($uploadOk == 0) {
                 $error = "Sorry, your file was not uploaded." . $error;
                 // if everything is ok, try to upload file
             } else {
                 $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
                 $query = new ParseQuery('Product');
                 $query->equalTo('objectId', $objectId);
                 $product = $query->first();
                 $product->set('name', $_POST['productName']);
                 $product->set('price', $price);
                 $product->set('description', $description);
                 $product->set('picture', $imageFile);
                 $product->save();
             }
         } else {
             $query = new ParseQuery('Product');
             $query->equalTo('objectId', $objectId);
             $product = $query->first();
             $product->set('name', $name);
             $product->set('price', $price);
             $product->set('description', $description);
             $product->save();
         }
     } else {
         if (isset($_POST['submit'])) {
             $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
             $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']);
             $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription'];
             if ($_FILES['fileToUpload']['size'] > 0) {
                 $target_file = basename($_FILES["fileToUpload"]["name"]);
                 $uploadOk = 1;
                 $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
                 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
                 if ($check !== false) {
                     //echo "File is an image - " . $check["mime"] . ".";
                     $uploadOk = 1;
                 } else {
                     //echo "File is not an image.";
                     $uploadOk = 0;
                 }
                 // Check file size
                 if ($_FILES["fileToUpload"]["size"] > 500000) {
                     $error = "Sorry, your file is too large." . $error;
                     $uploadOk = 0;
                 }
                 // Allow certain file formats
                 if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                     $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
                     $uploadOk = 0;
                 }
                 // Check if $uploadOk is set to 0 by an error
                 if ($uploadOk == 0) {
                     $error = "Sorry, your file was not uploaded." . $error;
                     // if everything is ok, try to upload file
                 } else {
                     $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
                     $product = new ParseObject('Product');
                     $product->set('name', $name);
                     $product->set('price', $price);
                     $product->set('description', $description);
                     $product->set('picture', $imageFile);
                     $product->save();
                 }
             } else {
                 $product = new ParseObject('Product');
                 $product->set('name', $name);
                 $product->set('price', $price);
                 $product->set('description', $description);
                 $product->save();
             }
             Url::redirect('product');
         }
         $sidemenu = new ParseQuery('SideMenu');
         $result = $sidemenu->find();
         Hooks::addHook('js', 'Controllers\\inventory\\Product@JS');
         Hooks::addHook('css', 'Controllers\\inventory\\Product@CSS');
         $data['title'] = 'สินค้า';
         $data['username'] = $currentUser->get('username');
         $data['sidemenu'] = $result;
         View::rendertemplate('header', $data);
         View::render('inventory/product', $data, $error);
         View::rendertemplate('footer', $data);
     }
 }