K
K
Korifa2018-03-15 16:34:24
PHP
Korifa, 2018-03-15 16:34:24

Why is the file not moving?

I am learning php trying to upload a file and move it to a folder here is the code

<?php
$path = '../';

//mkdir($path . 'alex');

if (isset($_REQUEST['add'])) {
  if ($f = action_upload_files($path) === False) {
    echo "File hasn't been uploaded";
  }
}

function action_upload_files($path) {
  if (move_uploaded_file($_FILES['upload']['tmp_name'], $path)) {
    return True;
  } else {
    return False;
  }
  
}
echo '<pre>';
var_dump($_FILES['upload']);
echo '</pre>';

?>

throws errors:
Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in C:\wamp64\www\project1\views\users.php on line 13
Warning: move_uploaded_file(): Unable to move 'C :\wamp64\tmp\php2286.tmp' to '../' in C:\wamp64\www\project1\views\users.php on line 13

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Korifa, 2018-03-15
@Korifa

And it turns out that move_uploaded_file() is copy() ?

L
leni_m, 2018-03-15
@leni_m

So they write to you in clear text that you are trying to save the file as a folder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question