Page 1 of 1

function to change filename not working

Posted: Tue Jan 16, 2007 4:53 am
by dhrosti
Iv been trying to get my head round whats going wrong for ages and cant figure out why this doesnt work...

Code: Select all

function filename() {
	// format: client_type_date.ext
	$client = $_POST['client'];
	$client = strtolower(str_replace(' ', '', $client));
	$type = $_POST['type'];
	$type = strtolower(str_replace(' ', '', $type));
	$date = date('d_m_Y');
	$mimetype = $_FILES['userfile']['type'];
	$ext = substr(strrchr($mimetype, "."), 1);
	return "$client_$type_$date.$ext";
}
It just returns "16_01_2007." as the filename. No underscores before $date, as id expect if the variables werent set.

Any help is much appreciated.

Posted: Tue Jan 16, 2007 5:04 am
by dude81
then it should be

Code: Select all

return $client._.$type._.$date.$ext;
:o

Posted: Tue Jan 16, 2007 5:05 am
by dhrosti
Right, i'v got the file extension fixed (my script was looking for a "." in a mimetype thing such as, image/jpeg)

Still not creating the $client or $type variables.

Posted: Tue Jan 16, 2007 5:09 am
by dhrosti
that sorted it, thanks.

just needed to put the dot before $ext in quotes