hey all i have been trying to get the ext from a file so that i can append it back on. but it seems not to be working here is what i have tried

$tempFile = $_FILES["Filedata"]["tmp_name"];
		$targetPath = $_POST["path"];
		
		$filename = $tempFile;
		$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
			  $ext = substr(strrchr($filename, '.'), 1);
			  $ext2 = '.'.$ext;

			  $randName = md5(rand() * time());
			  $filename = $randName . '.' . $ext;
echo $filename;

all it does is gives it the random name and adds the . with not ext added back on

You are never getting the file name. To get the file name you need to use

$filename = $_FILES["Filedata"]["name"];

cool that worked thanks. I know i had it working at one point in all my coding but it must of gotten lost in translation.

thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.