html - can't find my file after file upload in php -


i using following php script upload file:

<?php $dest_dir="c:\users\maria\documents\it-learning"; foreach ($_files $file_name => $file_array) {       echo "path: ".$file_array['tmp_name']."<br/>\n"; //output "c:\windows\temp\phpb4c9.tmp" instead     echo "name: ".$file_array['name']."<br/>\n";     echo "type: ".$file_array['type']."<br/>\n";     echo "size: ".$file_array['size']."<br/>\n";      if (is_uploaded_file($file_array['tmp_name'])) {         move_uploaded_file($file_array['tmp_name'], $dest_dir.$file_array['name'])         or die ("file exists can't moved");         echo "file uploaded successfully.";     } else {         echo "file not exist.";     } } //single file fine.  opened single file   ?> 

the output this:

path: c:\windows\temp\phpb4c9.tmp name: test2.xml type: text/xml size: 4523 file uploaded successfully. 

my problem don't see test2.xml file on computer except in original directory. understanding, should see moved c:\users\maria\documents\it-learning. don't see either in c:\users\maria\documents\it-learning or in c:\windows\temp\phpb4c9.tmp.

do miss-understand anything?

first, need careful backslashes in string literals:

$dest_dir="c:\\users\\maria\\documents\\it-learning"; 

you should double them prevent accidental special escape sequences.

second, missing trailing slash:

$dest_dir="c:\\users\\maria\\documents\\it-learning\\"; 

since missing last backslash, believe you'll find file named like:

c:\users\maria\documents\it-learningtest2.xml 

also, it's not secure trust user input as-is (e.g., name of file).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -