move_uploaded_file Directory Help

Hi I am using move_uploaded_file() to store a picture on my server but I am having problems getting the file to be stored in the correct directory. I want the file to be saved in a folder called 'pics' which is in the same directory as the .php file but it is always stored in the same directory as my .php file. Here is my code...

$updir = "pics/";
$upDir .= $_FILES['userfile']['name'];
$upDir = rawurlencode($upDir);

move_uploaded_file($_FILES['userfile']['tmp_name'], $upDir);

I've tried changing the line
$upDir = "pics/";
To many different thing but I always end up with the file saved in the parent directory of the pics folder (the parent directory of pics holds the .php file).

What am I missing? Thanks!


  • Nevermind I fixed it... Here is the code for reference...

    $upDir = "pics/".$_FILES['userfile']['name'];

    move_uploaded_file($_FILES['userfile']['tmp_name'], $upDir)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion