Something went wrong. Try again.
Open source inventory management system with php and mysql Invoice generation and easy to download invoice in PDF format Lightweight and ea…
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637<?php
require_once 'core.php';
$valid['success'] = array('success' => false, 'messages' => array());
if($_POST) {
$productId = $_POST['productId']; $type = explode('.', $_FILES['editProductImage']['name']); $type = $type[count($type)-1]; $url = '../assests/images/stock/'.uniqid(rand()).'.'.$type; if(in_array($type, array('gif', 'jpg', 'jpeg', 'png', 'JPG', 'GIF', 'JPEG', 'PNG'))) { if(is_uploaded_file($_FILES['editProductImage']['tmp_name'])) { if(move_uploaded_file($_FILES['editProductImage']['tmp_name'], $url)) {
$sql = "UPDATE product SET product_image = '$url' WHERE product_id = $productId";
if($connect->query($sql) === TRUE) { $valid['success'] = true; $valid['messages'] = "Successfully Updated"; } else { $valid['success'] = false; $valid['messages'] = "Error while updating product image"; } } else { return false; } // /else } // if } // if in_array $connect->close();
echo json_encode($valid); } // /if $_POST