Here my code of uploads.php
:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$uploads_dir = '/tmp' . DIRECTORY_SEPARATOR;
$tmp_name = $_FILES["file"]["tmp_name"];
$name = basename($_FILES["file"]["name"]);
echo move_uploaded_file($tmp_name, $uploads_dir . $name);
It returns 1
(aka true
) but the file is not copied to /tmp
.
If I set $uploads_dir
to a different directory with permissions 777 it works.
If the target directory is wrong or does not have the right permissions I get an error message.
The /tmp
directory as the correct permission I guess:
$ ls -l / | grep tmp
drwxrwxrwt 21 root root 20480 apr 21 17:39 tmp
so why it returns true
but does not copy anything there?
If your tmp directory is in the same level of the file uploads.php change:
to this:
Or if the folder it's in the root level (aka / ) You need to descend to the same level like:
I hope it's help you.