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]; ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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"); } Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.