stublackett Posted June 2, 2009 Share Posted June 2, 2009 Hi, I've got an Image Uploader working, Its just sometimes its tempremental when pulling the URL String from the database, So what I'd like to do is make the filename lowercase. I've looked at the function strtolower() but its where to put it in my code. Any help appreciated Here is my code $passport_photo = $_FILES['passport_photo']['name']; //Handle the Image // Set Upload DIR $uploaddir = "../../passports"; // Upload Part if(is_uploaded_file($_FILES['passport_photo']['tmp_name'])) { move_uploaded_file($_FILES['passport_photo']['tmp_name'],$uploaddir.'/'.$_FILES['passport_photo']['name']); } $passport_photo = $uploaddir."/".$passport_photo; $postData = "<a href='{$uploaddir}/{$passport_photo}'>Click To View Passport Photo</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/160673-solved-converting-an-filename-to-lower-case/ Share on other sites More sharing options...
anupamsaha Posted June 2, 2009 Share Posted June 2, 2009 Here: $passport_photo = strtolower($_FILES['passport_photo']['name']); And, move_uploaded_file($_FILES['passport_photo']['tmp_name'],$uploaddir.'/'.strtolower($_FILES['passport_photo']['name'])); Or, move_uploaded_file($_FILES['passport_photo']['tmp_name'],$uploaddir.'/'.$passport_photo); Quote Link to comment https://forums.phpfreaks.com/topic/160673-solved-converting-an-filename-to-lower-case/#findComment-847935 Share on other sites More sharing options...
Ken2k7 Posted June 2, 2009 Share Posted June 2, 2009 Why did you declare the variable $passport_photo without using it? You can use it on $passport_photo and then use it in the move_uploaded_file function. Quote Link to comment https://forums.phpfreaks.com/topic/160673-solved-converting-an-filename-to-lower-case/#findComment-847936 Share on other sites More sharing options...
stublackett Posted June 2, 2009 Author Share Posted June 2, 2009 Jackpot! Works a treat, Many Thanks! Ken, Where in that code did I not declare $passport_photo ? Quote Link to comment https://forums.phpfreaks.com/topic/160673-solved-converting-an-filename-to-lower-case/#findComment-847942 Share on other sites More sharing options...
Ken2k7 Posted June 2, 2009 Share Posted June 2, 2009 I didn't say you didn't declare $passport_photo. Look at your code. You assigned it to the value - $_FILES['passport_photo']['name']; - but you never used it. And when you did, it's to replace the value of $passport_photo again. Why not do that in the first place and use it in the move_uploaded_file function? Quote Link to comment https://forums.phpfreaks.com/topic/160673-solved-converting-an-filename-to-lower-case/#findComment-847946 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.