Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.