Hi I am still playing with an upload file script and having problem. I upload and copy the files but cannot hash its name. i use this code but the result is missing extention and so the file will not be opened what is the solution? thanks <?php $name= $_FILES["file"]["name"]; $ar=explode(".",$name); $ext=$ar[1]; move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); $newname=md5(time()); rename('uploads/'. $_FILES["file"]["name"],'uploads/'.$newname.$ext); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; ?> PHP:
$newname=md5(time()) . '.' . end(explode('.', $_FILES['file']['name'])); PHP: Don't rely on the extension being $ar[1], because the file can have a lot of dots, and faking the extension would be super easy. And remove this line: rename('uploads/'. $_FILES["file"]["name"],'uploads/'.$newname.$ext); PHP: Put the new name directly in the second parameter of move_uploaded_file().