adam291086 Posted February 4, 2008 Share Posted February 4, 2008 I want to change the new of a uploaded file. Will something like this work <?php $file_type= $_FILES["file"]["name"]; $name = $_POST['name']; $newfile = $_FILES["file"][$name]; ?> Link to comment https://forums.phpfreaks.com/topic/89428-solved-changing-a-file-name/ Share on other sites More sharing options...
cooldude832 Posted February 4, 2008 Share Posted February 4, 2008 no you can't alter that superglobal array nor can you adjust the parameters in it you can't do anything with whats in the temp except move it or get its data so you want to do a move_uploaded_File or copy() or something else similar to this. Link to comment https://forums.phpfreaks.com/topic/89428-solved-changing-a-file-name/#findComment-457941 Share on other sites More sharing options...
adam291086 Posted February 4, 2008 Author Share Posted February 4, 2008 i have got that part move_uploaded_file ($_FILES["file"]["tmp_name"] , $destination. $_FILES["file"]["name"]); how do i change the name then. Just i don't want to rely on the user uploading the correct file name Link to comment https://forums.phpfreaks.com/topic/89428-solved-changing-a-file-name/#findComment-457943 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 if(is_file($_FILES["image1"]["tmp_name"])) { move_uploaded_file($_FILES['image1']['tmp_name'],"images/destination/newfilename.extension"); } Link to comment https://forums.phpfreaks.com/topic/89428-solved-changing-a-file-name/#findComment-457976 Share on other sites More sharing options...
budimir Posted February 4, 2008 Share Posted February 4, 2008 You can use md5() to rename your file! That will do the trick. Link to comment https://forums.phpfreaks.com/topic/89428-solved-changing-a-file-name/#findComment-457988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.