Hi everyone,
I am working on a php script for which I can upload user info and a profile picture. Currently, with the script, the image is being renamed, but the image type (.jpg .jpeg .png, etc) isnt following the renaming. So, after I test-upload an image, it appears in my database with its uniqid name, but no file-type.
Here is my script:
[php]
if($_SERVER[“REQUEST_METHOD”] == “POST”) {
$file = $_FILES[‘file’];
$allowed = array(‘jpg’, ‘jpeg’, ‘png’);
$fileName = $_FILES['file']['name'];
$fileSize = $_FILES['file']['size'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileExt = explode('.', $fileTmpName);
$fileActualExt = strtolower(end($fileExt));
$uniqueName = substr(md5(time()), 0, 10).'.'.$fileActualExt;
$uploaded_image = "images/".$uniqueName.$fileActualExt;
move_uploaded_file($uniqueName, $uploaded_image);
$username = $connection->real_escape_string($_POST['name']);
$email = $connection->real_escape_string($_POST['email']);
$text = $connection->real_escape_string($_POST['text']);
[/php]
Any and all help is greatly appreciated!!
Thank you