I have this short, basic code:
<?php
$username = $_POST['User'];
$file = $_FILES['File'];
$size = $_FILES['File']['size'];
$name = $_FILES['File']['name'];
$temp_name = $file['tmp_name'];
$user_id = Data::getUserId($username);
$target_path = "/---/---/profile_pics/" . $name;
$sql = "INSERT INTO profile_photos (name, size, user_id)
VALUES ('{$name}', '{$size}', '{$user_id}');";
mysqli_query($dbconnection, $sql);
move_uploaded_file($temp_name, $target_path);
?>
Note, this is TESTING code so I may have not followed best practice.
I get the correct file information into my MySQL database. But I do not get the actual file moved in the directory.
Also, the database IS extracting the correct file size and file name so something is being passed to PHP that is accurate for sure.
I am passing the file from Java. Here is supplemental info on that end (in case anyone knows about that end; but I do not think the problem is here:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url_select);
File file = new File(imagePath);
HttpResponse response = null;
MultipartEntity entity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "image/jpeg");
StringBody sb;
try {
sb = new StringBody(userName);
entity.addPart("User", sb);
entity.addPart("File", cbFile);
post.setEntity(entity);
response = client.execute(post);
}