Warning: move_uploaded_file(uploads/Canon EOS 200D 24 2MP.jpg): failed to open stream: Permission denied in /home/vhosts/www.orbsportphysio.ml/ecomphp/admin/addproduct.php on line 27
Warning: move_uploaded_file(): Unable to move '/tmp/php810Ez4' to 'uploads/Canon EOS 200D 24 2MP.jpg' in /home/vhosts/www.orbsportphysio.ml/ecomphp/admin/addproduct.php on line 27
<?php
session_start();
require_once '../config/connect.php';
if(!isset($_SESSION['email']) & empty($_SESSION['email'])){
header('location: login.php');
}
if(isset($_POST) & !empty($_POST)){
$prodname = mysqli_real_escape_string($connection, $_POST['productname']);
$description = mysqli_real_escape_string($connection, $_POST['productdescription']);
$category = mysqli_real_escape_string($connection, $_POST['productcategory']);
$price = mysqli_real_escape_string($connection, $_POST['productprice']);
if(isset($_FILES) & !empty($_FILES)){
$name = $_FILES['productimage']['name'];
$size = $_FILES['productimage']['size'];
$type = $_FILES['productimage']['type'];
$tmp_name = $_FILES['productimage']['tmp_name'];
$max_size = 10000000;
$extension = substr($name, strpos($name, '.') + 1);
if(isset($name) && !empty($name)){
if(($extension == "jpg" || $extension == "jpeg") && $type == "image/jpeg" && $size<=$max_size){
$location = "uploads/";
if(move_uploaded_file($tmp_name, $location.$name)){
$sql = "INSERT INTO products (name, description, catid, price, thumb) VALUES ('$prodname', '$description', '$category', '$price', '$location$name')";
$res = mysqli_query($connection, $sql);
if($res){
header('location: products.php');
}else{
$fmsg = "Failed to Create Product";
}
}else{
$fmsg = "Failed to Upload File";
}
}else{
$fmsg = "Only JPG files are allowed and should be less that 1MB";
}
}else{
$fmsg = "Please Select a File";
}
}else{
$sql = "INSERT INTO products (name, description, catid, price) VALUES ('$prodname', '$description', '$category', '$price')";
$res = mysqli_query($connection, $sql);
if($res){
header('location: products.php');
}else{
$fmsg = "Failed to Create Product";
}
}
}
?>
What I have tried:
i had try to upload image in different ways but... still the same warning pls help me on this before i change to url image