php - Unable to move file from temp using move_uploaded_file() -


i tryin upload , store file (pdfs) in directory

i using move_uploaded_file such:

move_uploaded_file($_files["userdata"]["tmp_name"],       "uploads/data/" . $_files["userdata"]["name"]); 

the script runs when check directory via ftp nothing there.

permissions directory , parent directories 777.

i using enctype="multipart/form-data" in html form.

would know doing wrong?

var_dump($_files);

gives:

array(2) { ["userdata"]=> array(5) { ["name"]=> string(22) "myfile.pdf" ["type"]=> string(15) "application/pdf" ["tmp_name"]=> string(14) "/tmp/phpiujvu7" ["error"]=> int(0) ["size"]=> int(1398957) } ["userdata2"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } } 

my full code is:

$allowedexts = array("pdf", "doc", "docx", "wps", "odt"); $temp = explode(".", $_files["userdata"]["name"]); $extension = end($temp);  if ((($_files["userdata"]["type"] == "application/pdf") || ($_files["userdata"]["type"] == "application/msword") || ($_files["userdata"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_files["userdata"]["type"] == "application/vnd.ms-works") || ($_files["userdata"]["type"] == "iapplication/vnd.oasis.opendocument.text")) && ($_files["userdata"]["size"] < 4000000) && in_array($extension, $allowedexts)) {    if ($_files["userdata"]["error"] > 0) {     echo "return code: " . $_files["userdata"]["error"] . "<br>";    } else {     echo "upload: " . $_files["userdata"]["name"] . "<br>";     echo "type: " . $_files["userdata"]["type"] . "<br>";     echo "size: " . ($_files["userdata"]["size"] / 1024) . " kb<br>";     echo "temp file: " . $_files["userdata"]["tmp_name"] . "<br>";          if (file_exists("upload/data/" . $_files["userdata"]["name"])) {             echo $_files["userdata"]["name"] . " exists. ";         }           else {           move_uploaded_file($_files["userdata"]["tmp_name"],           "uploads/data/" . $_files["userdata"]["name"]);           echo "stored in: " . "upload/data/" . $_files["userdata"]["name"];         }   } }   else {   echo "invalid file"; } 

all if statements pass , not recieve errors.

your var_dump says file names in input html coverletter , resume, trying access $_files["userdata"]. try changing , may help

update :

uploads typo in move_uploaded_file()

also try checking move_uploaded_file this

if (move_uploaded_file($_files["userdata"]["tmp_name"],"upload/data/" . $_files["userdata"]["name"]);) {   echo "stored in: " . "upload/data/" . $_files["userdata"]["name"];  } else {  echo "move upload seems struct !" ;  } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -