Jgunzblazin Jgunzblazin - 4 months ago 16
PHP Question

temp file not getting placed in sub directory

Been trying to figure out why my

$temp
file will not get placed in the
$un
directory. The directory structure gets created but the temp file is not moved there. To verify a temp file is being created - if I remove the
mkdir()
the temp file is added to
uploads
folder
. How come the file is not being created in sub directory?

uploads/subfolder/


$temp = 'uploads/'.mkdir('uploads/'.$un) . md5($_FILES['image']['name']);

if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) {
// do something here..
}

Answer

Use like this,

  mkdir('uploads/'.$un);
  $temp = "uploads/$un/" . md5($_FILES['image']['name']);