5

I am uploading a file through PHP scipt ..

my code is

$file_temp=$_FILES["upl"]["tmp_name"];

when i upload stuffs with

move_upload_file($file_temp,"user_stuff/".$file_name)

Everything works fine .. stuff get uploaded with no disaster

But when i check the uploaded file to be actually in the area using

is_uploaded_file($file_temp);

It always return false

So i googled the problem and it redirected me to the same stackoverflow problem here

so i did , as it was suggested

 if(is_uploaded_file(realpath($file_temp)))
        {
            echo "done";
        }
        else
        {
            echo "fail";
        }

But still getting the same problem "fail"

Moreover, i just noticed a strange thing ... when i am not using move_uploaded_file(..) , the is_uploaded_file "works"

Community
  • 1
  • 1
Zafta
  • 655
  • 1
  • 10
  • 26

2 Answers2

1

try sudo chmod 777 path_to_directory/user_stuff/ -R in your console

BlackWhite
  • 814
  • 2
  • 12
  • 26
0

The is_uploaded_file function returns false since you are checking the destination of the file which doesn't exist as you have already moved the file to a new location using move_upload_file()

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
  • so now should i look for is_uploaded_file($file_name), as Fred-ii- suggested , but still not working – Zafta Oct 14 '13 at 05:14
  • 1
    For proper working, the function is_uploaded_file() needs an argument like $_FILES['userfile']['tmp_name'], - the name of the uploaded file on the client's machine $_FILES['userfile']['name'] does not work. – Zafta Oct 14 '13 at 05:20