$pimg="../pimages/".$_FILES[p_img][name];
move_uploaded_file($_FILES[p_img][tmp_name],$pimg);

image does not move into image folder

Hi Mary,

did the upload work? What does the output of

echo $_FILES[p_img][name]

say? Does your form have

enctype="multipart/form-data"

? And are uploads allowed by your php.ini-settings?

~Simon

$pimg="../pimages/".$_FILES[p_img][name];
move_uploaded_file($_FILES[p_img][tmp_name],$pimg);

image does not move into image folder

This may help

// The directory/place the files will be uploaded to.

   $pimg = "pimages/"; 
  
// Upload file to specified path.

   $pimg = $pimg . basename($filename);  
   
// Get the name of the file. 
  
   $filename = $_FILES['p_img']['name']; 
   
   
    if(move_uploaded_file($_FILES['p_img']['tmp_name'],$pimg . $filename))

Hi, please use this as a guide and try to implement it- it worked fine for me.
Also, use method POST, do not use GET
<?php

$name= $_FILES;// uploadit is the filename

$tmp_name= $_FILES;

$location= 'images/';

$to_insert= $location.$name ;// concat name and the images folder
if (move_uploaded_file($tmp_name,$location.$name)){
echo "File uploaded!";


$con = mysql_connect("localhost","root","");// connecting to host

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// selecting db
mysql_select_db("your_db", $con);

$query = "INSERT INTO images ";
$query .= "(locate) VALUES ('$to_insert')";
$results = mysql_query($query, $con);// locate is the column which contains the path

}// ending the big if statement

mysql_close($con);

?>

Use CODE tag to wrap the codes.

Member Avatar for diafol

I wonder if you've put the right enctype into the form attributes. You need this:

<form ...  enctype="multipart/form-data">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.