Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help to figure out to why is that image is not uploading. Here's the code createProduct.php

Can someone please help to figure out to why is that image is not uploading.

Here's the code

createProduct.php

require_once 'core.php';

$valid['success'] = array('success' => false, 'messages' => array());

if($_POST) {

$productName = $_POST['productName']; // $productImage = $_POST['productImage']; $quantity = $_POST['quantity']; $rate = $_POST['rate']; $brandName = $_POST['brandName']; $categoryName = $_POST['categoryName']; $productStatus = $_POST['productStatus'];

$type = explode('.', $_FILES['productImage']['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['productImage']['tmp_name'])) { if(move_uploaded_file($_FILES['productImage']['tmp_name'], $url)) { $sql = "INSERT INTO product (product_name, product_image, brand_id, categories_id, quantity, rate, active, status) VALUES ('$productName', '$url', '$brandName', '$categoryName', '$quantity', '$rate', '$productStatus', 1)";

if($connect->query($sql) === TRUE) { $valid['success'] = true; $valid['messages'] = "Successfully Added"; } else { $valid['success'] = false; $valid['messages'] = "Error while adding the members"; }

} else { return false; } // /else } // if } // if in_array

$connect->close();

echo json_encode($valid); } // /if $_POST

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago