Example #1
0
         $response['data'] = $data;
         $rest = new product_server();
         $rest->handle_response($response['data'], 200);
     } else {
         $rest = new product_server();
         $response['data'] = 'Product not found';
         $rest->handle_response($response['data'], 400);
     }
 } else {
     //insert action
     $pro = new Product();
     /************************/
     $name_img = $_FILES['image']['name'][0];
     $type_img = $_FILES['image']['type'][0];
     $tmp_name_img = $_FILES['image']['tmp_name'][0];
     $id = $pro->getmaxid();
     // mkdir($id);file:///var/www/html/Eshopper/admin/image/categories/subcat/as.jpg
     move_uploaded_file($tmp_name_img, "/var/www/html/Eshopper/admin/image/categories/subcat/" . $name_img);
     $defolt_path = "http://localhost/Eshopper/admin/image/categories/subcat/";
     $image_pathe = $defolt_path . "/{$name_img}";
     /************************/
     // print_r($_POST);
     $pro->name = $_POST['name'];
     $pro->des_product = $_POST['des_product'];
     $pro->quantity = $_POST['quantity'];
     $pro->price = $_POST['price'];
     $pro->image = $image_pathe;
     $pro->cat_id = $_GET['cat_id'];
     print_r($pro);
     $pro->id = $pro->insert();
     if ($pro->id > 0) {
Example #2
0
<?php

include "classes/product.php";
$pro = new Product();
$x = $pro->getmaxid();
echo "ssssssssssssss";
echo "<h1>ddddddd</h1>";
print_r($x);
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
	<script type="text/javascript">
	// 	$(function(){
	// 		$("#submit").click(function(){
	// 			var fd = new FormData();
				
	// 			$.each($("form").serializeArray(),function(index,value){
					
	// 				var obj=$(this)[0];
	// 				console.log(obj);
	// 				console.log(obj.name);
	// 				console.log(obj.value);
	// 				fd.append("'"+obj.name+"'","'"+obj.value+"'");
	// 			});
	// 			var upload_element=document.getElementById("file_input");
	// 			fd.append("file[]",upload_element.files[0]);