database - JPG Image extension not inserting into Custom table of wp

admin2025-06-03  3

I've created a custom table on database and I need to upload image from my template page member. In this page I've done all the codings. I'm able to insert data but stuck on the image insert. I can get the file name but unable to get the extension.

Here is my inserting code of my template file.

$tmpfile = explode(".", $_FILES['image']['name']);
$newfile = round(microtime(true)) . '.' . end($tmpfile);
move_uploaded_file($_FILES['image']['tmp_name'], ABSPATH . '/wp-content/themes/themename/inc/images/' . $newfile);

$sql = $wpdb->query($wpdb->prepare("INSERT INTO members(member_image) VALUES (%s)", $newfile));

The above code shows the field value without extension as:

Here is my html form field:

<form action="" method="post">
    <input type="file" name="image" class="form-control">
 </form>

All other text fields are inserted but only image can't be derived with extension. I can't figure out the problem. I've also tried by adding .jpg extension but it didn't work.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748924756a314866.html

最新回复(0)