0

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

image does not move into image folder

6
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by diafol
0

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

Edited by sDJh: n/a

0

$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))
0

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);

?>

0

Use CODE tag to wrap the codes.

Edited by happygeek: fixed formatting

0

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

<form ...  enctype="multipart/form-data">
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.