PHP interesse | 
                 | 
                
				
				Ik heb een fotoupload scriptje, 
echter er zit een klein probleempje in. 
 
Hoe vervang ik de spaties in de filenames door b.v. een _ ? 
 
Weet iemand hier een oplossing voor ? 
 
    
    
        
            
                <?
session_start();
include 'includes/custom_settings.inc.php';
include $language_path.'/uitloggen.lng.php';
include 'includes/TemplatePower.inc.php';
$tpl = new TemplatePower($template_path.'/fotoupload.tpl');
$tpl->assignInclude('header', $template_path.'/header.tpl');
$tpl->assignInclude('menu', $template_path.'/menu.tpl');
$tpl->assignInclude('footer', $template_path.'/footer.tpl');
$tpl->prepare();
include 'includes/config.inc.php';
if ($ingelogd == 0) header('Location: index.php');
$mapnaam = "memberfotos/".$memberid."/fotos/";
$actie = $_POST['actie'];
if ($actie == "upload") {
    $extensions = array();
    $extensions['ext'][] = "image/gif";
    $extensions['ext'][] = "image/jpg";
    $extensions['ext'][] = "image/jpeg";
    $extensions['ext'][] = "image/pjpeg";
    $extensions['ext'][] = "image/png";
    $extensions['ext'][] = "image/x-png";
    if(in_array($_FILES['foto']['type'], $extensions['ext'])) {
        if($_FILES['foto']['size'] > 1048576) {
            $tpl->newBlock('fout');
			$tpl->assign('foutmelding','Uw bestand is meer als 1 MB (1024 KB)!<br>Klik <a href="javascript:history.back(1)<br>">hier</a> om terug te gaan!');
        } else {
            if($_FILES['file']['type'] == "image/gif") {
                $ext = ".gif";
            } elseif($_FILES['foto']['type'] == "image/jpg") {
                $ext = ".jpg";
            } elseif($_FILES['foto']['type'] == "image/jpeg") {
                $ext = ".jpg";
            } elseif($_FILES['foto']['type'] == "image/pjpeg") {
                $ext = ".jpg";
            } elseif($_FILES['foto']['type'] == "image/png") {
                $ext = ".png";
            } elseif($_FILES['foto']['type'] == "image/x-png") {
                $ext = ".png";
            }
            if(file_exists($mapnaam.$_FILES['foto']['name'])) {
                unlink($mapnaam.$_FILES['foto']['name']);
            }
            if(is_uploaded_file($_FILES['foto']['tmp_name'])) {
                move_uploaded_file($_FILES['foto']['tmp_name'], $mapnaam.$_FILES['foto']['name']);
				mysql_query("UPDATE leden SET bewerkdatum  = '$site_dag', bewerktijd = '$site_tijd' WHERE id = '$id'");
				mysql_query("INSERT INTO fotos (id, userid, filename, tekst) VALUES ('','$memberid','".$_FILES['foto']['name']."','')");
				$tpl->newBlock('gelukt');
				$tpl->assign('melding','Uw bestand is succesvol geupload!');
				header("Location: fotoalbum.php");
            } else {
                $tpl->newBlock('fout');
				$tpl->assign('foutmelding','Er is iets fout gegaan tijdens het uploaden!<br>
				Probeert het nogmaals..<br>
				Klik <a href="javascript:history.back(1)">hier</a> om terug te gaan!');
            }
        }
    } else {
        $tpl->newBlock('fout');
		$tpl->assign('foutmelding','Er is een bestand gekozen dat niet de extensie .gif, .jpg, .jpeg, .png of .bmp heeft!<br>
		Klik <a href="javascript:history.back(1)">hier</a> om terug te gaan!<br>
		<br>');
   	}
} else {
}
$tpl->PrintToScreen();
?>
             
            <? include 'includes/custom_settings.inc.php'; include $language_path.'/uitloggen.lng.php'; include 'includes/TemplatePower.inc.php';   $tpl = new TemplatePower($template_path.'/fotoupload.tpl'); $tpl->assignInclude('header', $template_path.'/header.tpl'); $tpl->assignInclude('menu', $template_path.'/menu.tpl'); $tpl->assignInclude('footer', $template_path.'/footer.tpl'); $tpl->prepare();   include 'includes/config.inc.php';   if ($ingelogd == 0) header('Location: index.php');   $mapnaam = "memberfotos/".$memberid."/fotos/";     $actie = $_POST['actie']; if ($actie == "upload") {     $extensions['ext'][] = "image/gif";     $extensions['ext'][] = "image/jpg";     $extensions['ext'][] = "image/jpeg";     $extensions['ext'][] = "image/pjpeg";     $extensions['ext'][] = "image/png";     $extensions['ext'][] = "image/x-png";     if(in_array($_FILES['foto']['type'], $extensions['ext'])) {         if($_FILES['foto']['size'] > 1048576) {             $tpl->newBlock('fout'); 			$tpl->assign('foutmelding','Uw bestand is meer als 1 MB (1024 KB)!<br>Klik <a href="javascript:history.back(1)<br>">hier</a> om terug te gaan!');         } else {             if($_FILES['file']['type'] == "image/gif") {                 $ext = ".gif";             } elseif($_FILES['foto']['type'] == "image/jpg") {                 $ext = ".jpg";             } elseif($_FILES['foto']['type'] == "image/jpeg") {                 $ext = ".jpg";             } elseif($_FILES['foto']['type'] == "image/pjpeg") {                 $ext = ".jpg";             } elseif($_FILES['foto']['type'] == "image/png") {                 $ext = ".png";             } elseif($_FILES['foto']['type'] == "image/x-png") {                 $ext = ".png";             }                 unlink($mapnaam.$_FILES['foto']['name']);             } 				mysql_query("UPDATE leden SET bewerkdatum  = '$site_dag', bewerktijd = '$site_tijd' WHERE id = '$id'"); 				mysql_query("INSERT INTO fotos (id, userid, filename, tekst) VALUES ('','$memberid','".$_FILES['foto']['name']."','')"); 				$tpl->newBlock('gelukt'); 				$tpl->assign('melding','Uw bestand is succesvol geupload!'); 				header("Location: fotoalbum.php");             } else {                 $tpl->newBlock('fout'); 				$tpl->assign('foutmelding','Er is iets fout gegaan tijdens het uploaden!<br> 				Probeert het nogmaals..<br> 				Klik <a href="javascript:history.back(1)">hier</a> om terug te gaan!');             }         }     } else {         $tpl->newBlock('fout'); 		$tpl->assign('foutmelding','Er is een bestand gekozen dat niet de extensie .gif, .jpg, .jpeg, .png of .bmp heeft!<br> 		Klik <a href="javascript:history.back(1)">hier</a> om terug te gaan!<br> 		<br>');    	} } else { }     $tpl->PrintToScreen(); ?> 
 
  
         
          
     
  				
				 |