I am just learning php the way it works and trying to upload the file using move_uploaded_file
. The code i have written seems perfect but at the end it is generating a warning message. I am giving my code
<?php
if(isset($_POST['create'])){
$productcatid=$_POST['productcategory'];
$name = ucfirst(trim($_POST['itemname']));
if(isset($_POST['status'])){
$status = true;
}
else{
$status = false;
}
if(isset($_POST['availability'])){
$avalability = true;
}
else{
$avalability = false;
}
$c=$_POST['price'];
$d=$_POST['type'];
$e=$_POST['brandname'];
$f=$_POST['datecreated'];
$g=$_POST['size'];
$h=$_POST['colour'];
$i=$_POST['fabric'];
if(isset($_FILES['upload'])){
$file = $_FILES['upload'];
$n = $file['name'];
$s = $file['size'];
$tm = $file['tmp_name'];
$er = $file['error'];
$target = 'uploadedfiles/'.$n;
if(move_uploaded_file($tm, $target)){
$sql = "insert into product_items(item_name, is_active, category_id, image_url, date_created, is_item_available, type, brand_name, fabric, size, colour,price) ";
$sql .= " values('".$name."','".$status."','".$productcatid."','".$upload."','".$f."','".$avalability."','".$d."','".$e."','".$i."','".$g."','".$h."','".$c."')";
include('config.php');
$res = mysql_query($sql);
if($res){
//header('Location:allproductitemcategory.php');
echo 'success';
}
else{
echo mysql_error();
}
}
else{
echo 'error uploading file. '.$er;
}
}
}
else{
echo 'error';
}
?>
It is giving a following warning
Warning: move_uploaded_file(uploadedfiles/s3.jpg)
failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/onlineshopping/insertproductitems.php
on line 38
Warning: move_uploaded_file()
: Unable to move '/Applications/XAMPP/xamppfiles/temp/php6TeZrH'
to 'uploadedfiles/s3.jpg'
in /Applications/XAMPP/xamppfiles/htdocs/onlineshopping/insertproductitems.php
on line 38
error uploading file. 0
I am just stuck here as I am not able to get it. Please help