Replacing or removing portuguese characters from filename

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xamonix
Forum Newbie
Posts: 6
Joined: Fri Sep 24, 2010 8:42 am

Replacing or removing portuguese characters from filename

Post by xamonix »

Hi !

I got this script to upload images, but as a portuguese website I need to clean or replace the portuguese characters like "ã" or "ç" from user's filename. The script is the following. What lines should I add to the script to get the desired result?

Code: Select all

$userfile2=(isset($_FILES['userfile']['tmp_name']) ? $_FILES['userfile']['tmp_name'] : "");
		$userfile_name=(isset($_FILES['userfile']['name']) ? $_FILES['userfile']['name'] : "");
		$imagesize = $_FILES['userfile']['size'];

		if (( $imageenabled == 2 ) || ( ($imageenabled == 1) && (!empty($userfile_name)) ) ) {
			$base_Dir = ELPATH.'/../../images/eventlist/events/';
			$sizelimit = $sizelimit*1024; //size limit in kb

			if (!move_uploaded_file ($_FILES['userfile']['tmp_name'],$base_Dir.$_FILES['userfile']['name']) || !mosChmod($base_Dir.$_FILES['userfile']['name'])) {
				echo "<script> alert('Image not sent!.'); window.history.go(-1); </script>\n";
			    exit();
			} else {
				$file = $base_Dir.$userfile_name;
				//chmod Bild
				@chmod ($file, octdec($imagechmod));
				//Vorbereiten auf Thumbnailerstellung
				$thumbdir = $base_Dir.'small/';
				$save = $thumbdir.$userfile_name ;
				if ($imageprob = 1) {
					$imageprob = TRUE;
				} else {
					$imageprob = FALSE;
				}
				if ($gddisabled == 1) {
				evlist_imgd::thumb($file, $save, $imagewidth, $imagehight, $imageprob);
				}
			}
			$_POST['datimage'] = $userfile_name ;
		}
Thank you for your time and help!
Post Reply