Hey I am working on renaming a file on upload so far I have managed to put the new name infront of the old name this is my code $path1= "images/".$logged_in_user."_". $_FILES['ufile']['name']; move_uploaded_file($_FILES['ufile']['tmp_name'], $path1); PHP: how do I rename the file so it is just $logged_in_user And before you say, then i may over wright old images, good I want it so users can have only one image, if they upload a new image, it deletes the old one, instead of me having dead images floating about. Anybody
Don't work (or i am doing it wrong) $path1= "images/".$_FILES['ufile']['name'] =$_FILES['ufile'][$logged_in_user]; move_uploaded_file($HTTP_POST_FILES['ufile']['tmp_name'], $path1); and I get this Warning: move_uploaded_file(images/): failed to open stream: Is a directory in /home/bla/public_html/site/folder/upload_picture.php on line 35 Warning: move_uploaded_file(): Unable to move '/tmp/phpTHU0gj' to 'images/' in /home/bla/public_html/site/folder/upload_picture.php on line 35 Your file has been uploaded
Use: $file_ext = substr($_FILES['ufile']['name'], strrpos($_FILES['ufile']['name'], '.')+1); // get the file extension, like .gif, .jpg etc.. $file_name = "images/" . $logged_in_user . '.' . $file_ext; move_uploaded_file($_FILES['ufile']['tmp_name'], $file_name); PHP:
Thank you "Important" Perfect That is what i was planning to build (all i needed was a lil more knowledge)