Jump to content

[SOLVED] Converting an Filename to Lower Case


stublackett

Recommended Posts

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>";

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);

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.