Home >>Advance PHP Tutorial >HomeHow to Rename image during upload
<?php if ($_POST['upload'] ) { $user=$_POST['c']; //$filename=basename($_FILES["file"]["name"]); $tmp=$_FILES["file"]["tmp_name"]; $extension = explode("/", $_FILES["file"]["type"]); $name=$user.".".$extension[1]; move_uploaded_file($tmp, "upload/" . $user.".".$extension[1]); echo "Your file is uploaded with ".$user." name"; } ?> <html> <body> <form enctype="multipart/form-data" method="post"> Your New file name<input type="text" name="c"/><br/> choose your file <input type="file" name="file"/><br/> <input type="submit" value="Upload" name="upload"/> </form> </body> </html>