$path = '../../images/products/' . $_POST['cNames_menu_edit'] . '/' . $_POST['scNames_menu_edit'] . '/' . time() . '.' . $type[1];
        // echo $type
        // $allowed_types = array('image/png','image/jpg','image/jpeg');
        // if(!in_array($type,$allowed_types))
        // {
        // 	echo 'plz, upload image type';
        // }
        // else if($size > 42565433)
        // {
        // 	echo 'plz, dun exceed the max limit of size';
        // }
        //  else
        // {
        move_uploaded_file($tmp_name, $path);
        chmod($path, 0777);
        // echo "<img src='images/$name'/>";
        // }
        $products = new product();
        $products->pName = $_POST['insert_pName'];
        $products->scID = $_POST['scNames_menu_edit'];
        $products->pPrice = $_POST['insert_pPrice'];
        $products->pQuantity = $_POST['insert_pQuantity'];
        $products->pImg = $path;
        $products->pDesc = $_POST['insert_pDesc'];
        $id = $products->insert();
    } else {
        $_SESSION['errors'] = $arrErrors;
    }
    header("Location: adminProducts.php");
    exit;
}
        //echo $pid;
        $subType_id = $_POST['scatname'];
        $pname = $_POST['pname'];
        $desc = $_POST['desc'];
        $quantity = $_POST['quantity'];
        $price = $_POST['price'];
        //$date=date("d/m/y");
        $pdate = $_POST['pdate'];
        //$pdate=now();
        //$pdate=strtotime('$pd','%d-%m-%Y');
        $product_img = $_FILES['image']['tmp_name'];
        $imgname = $_FILES['image']['name'];
        $type = $_FILES['image']['type'];
        if (in_array($type, array('image/jpeg', 'image/png', 'image/jpg', 'image/gif'))) {
            move_uploaded_file($product_img, "../images/items/{$imgname}");
            $p = $product->insert($pname, $desc, $quantity, $imgname, $subType_id, $price, $pdate);
        }
        //header("location:addProduct.php");
    }
}
include 'Aheader.php';
?>

<form action="addProduct.php" enctype="multipart/form-data" method="post">	
<div id="inside">
	<div class="container">
	<div class="row">
    <div class="col-md-9 personal-info">
        <table class="table table-bordered table-hover table-striped table-responsive">
		<tr><th colspan="3"><h2>Add new product</h2></th></tr>
		<tr>
Exemple #3
0
        $_REQUEST['onhome'] = false;
    }
    $product = new product();
    $product->setReference($_REQUEST['reference']);
    $product->setContent($_REQUEST['title_1'], $_REQUEST['content_1'], $_REQUEST['title_2'], $_REQUEST['content_2'], $_REQUEST['title_3'], $_REQUEST['content_3'], $_REQUEST['title_4'], $_REQUEST['content_4'], $_REQUEST['title_5'], $_REQUEST['content_5'], $_REQUEST['title_6'], $_REQUEST['content_6'], $_REQUEST['code']);
    $product->setService($_REQUEST['service']);
    $product->setPrice($_REQUEST['price']);
    $product->setVAT($_REQUEST['vat']);
    $product->setDiscount($_REQUEST['discount']);
    $product->setUserId($account['name']);
    $product->setCategory($_REQUEST['category']);
    $product->setDate();
    $product->setDateUpdate();
    $product->setPublished($_REQUEST['published']);
    $product->setonHome($_REQUEST['onhome']);
    if ($product->insert()) {
        print 'sucess';
        $id = $mysqli->insert_id;
        ?>
			<div class="separator30"></div>

			<span id="label">Lista de ficheiros</span>
			<?php 
        print returnFilesList($id, 'product');
        ?>

			<div class="separator30"></div>

			<?php 
        print returnImgUploader('IMG Uploader', $id, 'product', '290', 350);
        print ' ';