so i have

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file"><br><br>
    <input type="submit" value="Upload">

$file_name = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];

if (isset($file_name)) {
    if (!empty($file_name)) {
        $location = '/user/'.$_SESSION['Username'].'/';
        if (move_uploaded_file($tmp_name, $location.$file_name)) {
            echo 'Uploadat!';   
    } else {
        echo 'Te rugam alege o imagine!';   


and is not working it says "Unable to move '/tmp/phppQNtB5' to '/user/axxxA/back_view.jpg' in /home/user/public_html/user/axxxA/upload.php on line 20"

Does the user/ folder and it's sub-folders have write permissions?

the permissions in filezilla are 0755 for the folders

Member Avatar


 $location = '/user/'.$_SESSION['Username'].'/';

This will write to root/user/... probably not what you want.

 $location = 'user/'.$_SESSION['Username'].'/';

but how to move it into the same page with the script?

doesn't work with

$location = 'user/'.$_SESSION['Username'].'/';

it says "Warning: move_uploaded_file(user/axxxA/file.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/user/public_html/user/axxxA/upload.php on line 20"
and "Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpomrzCU' to 'user/axxxA/file.txt' in /home/user/public_html/user/axxxA/upload.php on line 20"

Do both folders exist?

the user exist the other one i can't check it i'm on a free host

If it doesn't exist you have to create it first. See is_dir and mkdir.

i did

if (is_dir($tmp_name = $_FILES['file']['tmp_name'])) {
    echo 'the temporary folder exists<br>';
} else {
    echo 'the temp folder doesn\'t exist<br>';

if (is_dir('/user'.$_SESSION['Username'])) {
        echo 'the temporary folder exists';
} else {
    echo 'the main folder doesn\'t exist';

i get the negative answers
but for the second i know for sure it exists

what if i define the location of the temp file or folder in my "public_html"

when i try

echo $tmp_name = $_FILES['file']['tmp_name'];

nothing is displayed

well i get an echo of $tmp_name after the function is called