I would like to know how to rename an avatar before/upon its uploaded , I have searched around and also tried a few changes to my code , I already have managed to get the photo to
$move_file = move_uploaded_file($file['tmp_name'], $upload_image_to_folder.$new_file_name);
$new_file_name = $username
Possibly you are missing to add a file extension to the filename...
You can try this:
$filetype = pathinfo(basename($_FILES["fileToUpload"]["name"]),PATHINFO_EXTENSION); $target_file = $target_dir . $username . "." . $filetype;
Now this will convert the name to the
$username and append it's original file extension...
Next you can use:
P.S - This code is with reference for your situation that file is Sent to PHP via a form having variable name
fileToUpload in HTML code... You might Need to Change accordingly, because I don't know your whole code...
Hope this helps... :)