Reputation: 1388
I am simply trying to move an uploaded file to a location on my server. Here is my code.
$target_path = $_SERVER['DOCUMENT_ROOT'] . "img/uploads/";
$target_path = $target_path . basename($_FILES['imageURL']['tmp_name']);
if (move_uploaded_file($_FILES['imageURL']['tmp_name'], $target_path)) {
echo "The file has been moved";
} else {
echo "There was an error.";
}
I keep getting the error for false and I can't figure out why it won't move it. I've verified the location of it with an if statement it results in true.
I edited the name path for the tmp_name in the array..still hasn't worked. I did a dump and I have no tmp_key for that array. Why am I not getting the key?
Upvotes: 0
Views: 78
Reputation: 57719
$_FILES['imageURL']['name']
is the name of the file, not the location in the OS-temp directory.
I think you need to use $_FILES['imageURL']['tmp_name']
.
Upvotes: 3