0

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

Edited by itisnot_me: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by itisnot_me
0

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

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

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.