Lassie Posted March 1, 2011 Share Posted March 1, 2011 I want to save an image with a unique name that is created from a hash function. How can I cretae the path with the variable... $hash=$_GET['hash']; $path ="/Applications/MAMP/htdocs/test_upload/images/imagename2.png"; //becomes $path ="/Applications/MAMP/htdocs/test_upload/images/'.$hash.'.png";? Link to comment https://forums.phpfreaks.com/topic/229251-create-file-path-with-a-variable/ Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Share Posted March 1, 2011 $hash = substr(md5(uniqid(rand(), true)), 0, 20); $path = "/Applications/MAMP/htdocs/test_upload/images/".$hash.".png"; rename("/Applications/MAMP/htdocs/test_upload/images/imagename2.png", "/Applications/MAMP/htdocs/test_upload/images/".$hash.".png"); Link to comment https://forums.phpfreaks.com/topic/229251-create-file-path-with-a-variable/#findComment-1181278 Share on other sites More sharing options...
Lassie Posted March 1, 2011 Author Share Posted March 1, 2011 Thanks thats done it. Link to comment https://forums.phpfreaks.com/topic/229251-create-file-path-with-a-variable/#findComment-1181281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.