V
V
vahan212022-02-03 23:42:43
linux
vahan21, 2022-02-03 23:42:43

move_uploaded_file false?

Hi all. I am working on linux ubuntu. move_uploaded_file doesn't work for me. How can I fix this.

$file_name = $_FILES['img']['name'];
    $file_tmp = $_FILES['img']['tmp_name'];
    $img_hash = time()."_".rand(1000, 9999)."_".$file_name;
    // move_uploaded_file($_FILES['img']['tmp_name'], $file_name);
    if (move_uploaded_file($file_tmp," ../user/user_img/".$img_hash)) {
        echo "File is valid, and was successfully uploaded.\n";
    } else {
        echo "Upload failed";
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2022-02-04
@ThunderCat

ini_set('error_reporting',E_ALL);
ini_set('display_errors', 1);

1) paths must always be absolute for file operations. You have some kind of incomprehensible folder, lying incomprehensibly where, one level above it is not clear what.
2) A space in the path, before the "..", is it really so difficult to follow what you write.
0) Read the errors carefully , in your case, most likely there is no such folder, or rather, it is not where you came up with it for yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question