I coding a simple uploader , but I stuck in one step , I wanna use the filter for my uploader so the uploader filters some extensions ,
I no the ways such as using mime to get the type of the content ,
<html> <head> <title>Uploader</title> </head> <body> <form action="index.php" method="POST" enctype="multipart/form-data" > <input type="file" name="myfile" /> <input type="submit" name="submit" value="Upload" /> </form> <?php $path = 'uploads/'; if(!is_dir($path)) { mkdir($path); } if(isset($_POST['submit'])) { $file_path = $path.$_FILES['myfile']['name']; if(!eregi('', $_FILES['myfile']['name'])) { if(!empty($_FILES['myfile']['name'])) { if(move_uploaded_file($_FILES['myfile']['tmp_name'], $file_path)) { echo 'Your file has been uploaded successfully!'; } else { echo 'Error in uploading the file'; } } else { if(empty($_FILES['myfile']['name'])) { echo 'You did not select any file ... .'; } } } else { echo 'Oh, invalid file!'; } } ?> </body> </html>As you can see the code , here I used this function :
if(!eregi('', $_FILES['myfile']['name']))To filter the extension but I don't know this annoying regular expression stuff !!!!!! ( It's annoying me badly if you have any effective solution or program that I can give the regex and get the result introduce me with )
I can also use something to walk through the array but I cut php for sometime and I've done some python stuff so I forgot how to walk through and array for example associative array and check the value of the array with specific value that I've inserted !
I mean for example I wanna check username and password in this array :
<?php $username = 'Jacek'; $password = 'Betterphp'; $list = array('Jacek'=>':D','Jacek'=>':(','Jacek'=>'Why Jacek ?','Jacek'=>'Betterphp'); if($username == $list and $password == $list) { // Do something with jacek here } ?>As you can see I wanna check username and password in this array how can I do this ?