It looks like you're new here. If you want to get involved, click one of these buttons!
<?php
$str = ' This is a test ';
$count = 1;
while($count)
$str = str_replace(' ','', $str, $count);
echo $str;
?>
$fname="Filen'ame 1\/23;".'"'."la\l[a]*(/.jpg";
$replace="_";
$pattern="/[^a-zA-Z0-9\.]/";
$fname=preg_replace($pattern,$replace,$fname);
$fname=str_replace($replace,'',$fname);
echo '<br>'.$fname;
$var =$_FILES['Filedata']['name'];
$name= ereg_replace(" ","_",$var);
$targetFile = str_replace('//','/',$targetPath) . $name; <?php
if (!empty($_FILES)) {
$replace="_";
$newfile= $_FILES['Filedata']['name'] ;
$ext = substr($newfile,-4); //comment out to not ramdomize the filename
$pre = mb_split($ext,$newfile); //comment out to not ramdomize the filename
$randoms = base_convert(mt_rand(0x1679616, 0x39AA3FF), 10, 36); //comment out to not ramdomize the filename
$newfile = $pre[0].$randoms.$ext; //comment out to not ramdomize the filename
$pattern="/[^a-zA-Z0-9\.]/";
$newfile = preg_replace($pattern,$replace,$newfile);
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $newfile;
move_uploaded_file($tempFile,$targetFile);
chmod($targetFile,0777);
echo $newfile; // Required to trigger onComplete function on Mac OSX (same for linux and windows as it seems)
//and to send back the new filename to the 'response' variable in uploadify
}
else { // Required to trigger onComplete function on Mac OSX
echo 'ERROR!';
}
?>
$fileArray = array();
$replace="_";
$pattern="/[^a-zA-Z0-9\.]/";
foreach ($_POST as $key => $value) {
if ($key != 'folder') {
$value= preg_replace($pattern,$replace,$value);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $_POST['folder'] . '/' . $value)) {
$fileArray[$key] = $value;
}
}
}
echo json_encode($fileArray);