I posted this on Stack Overflow, but I’ve gotten minimal response there.
I have a file upload page, and I have gone through the code and inserted debugging lines incrementally, line-by-line, to try to find the cause of this problem. The problem occurs somewhere in this block of code:
[php] $tmp_name = $_FILES[‘image_large’][‘tmp_name’];
chdir(’…’.DIRECTORY_SEPARATOR.‘photos’);
$name = getcwd().DIRECTORY_SEPARATOR.$_FILES[‘image_large’][‘name’];
$success = move_uploaded_file($tmp_name,$name);
$errormsg = “
source: {$tmp_name}
destination: {$name}
”;$errormsg .= “
did it upload: {$success}
”;[/php]This $errormsg gets printed on the page, and displays the following result:
[code]source: C:\xampp\tmp\php4A14.tmp
destination: C:\xampp\htdocs\photos\fingerlakes1.jpg
did it upload: 1[/code]
That destination is the correct, intended location for the file to go. Yet when I check, there is no file “C:\xampp\htdocs\photos\fingerlakes1.jpg” produced, even though the debugging results seem to suggest the computer is convinced it performed the task successfully.
I have also made sure the folder has write permissions enabled (I’m on Windows 7), although I think that if that were the cause, $success would not have evaluated as true. I should also mention that there is another block of code very similar to the above for $_FILES[‘image_thumb’], but it is commented out for now.
I also tried using print_r($_FILES) to check everything, and it returned:
Array ( [image_large] => Array ( [name] => fingerlakes1.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\php5694.tmp [error] => 0 [size] => 497376 ) [image_thumb] => Array ( [name] => fingerlakes1.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\php5695.tmp [error] => 0 [size] => 26228 ) )
So it appears that the files are uploaded correctly to the tmp folder, at least.
Further information in case it helps: I am using XAMPP, with the XAMPP Control Panel running in Administrator Mode. I am only local-testing right now (in other words, the file upload should merely copy the file from one part of my computer to another). I went into the destination folders “photos” and “thumbnails” and did right-click -> properties -> Security, and made sure that every single user listed has write access, just to make sure. There is only one account on this computer, but it listed the account name twice as user and administrator, plus SYSTEM and one other one I forget. But I gave them all write access to be on the safe side.
In addition, I have noticed that every folder on my C drive, when I right-click it and choose Properties, has the box “read-only” checked… every single folder. Yet I can save and write files just fine other than this issue, and unchecking that box only lasts until I close the Properties box; when I reopen it the read-only box is checked again. I doubt this is the problem since it’s not stopping me from saving other files I am working on.