I just want to make sure I’m doing this right. This is a simple upload class. I need to change the below code to rename the actual image file, with a variable name (a Joomla user id and keep the extension of course. It’s easy to get the logged in user id. So my image filename before upload would be whatever the user had (usersimagename.jpg) and have it changed to a numeric userid.ext like (62.png) populated by joomla’s user variable.
<?php
$uploaddir = $_REQUEST['path'];
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "success";
} else {
// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
// Otherwise onSubmit event will not be fired
echo "error";
}
?>
If I understand your question right you want to keep the file extension while changing the actual name for storage. I don’t know the Joomla variable but something like this should work
Then follow this up with the rest of your code.
You could also substitute $JOOMLAID with whatever generated name you can think of.