Brian W Posted September 15, 2008 Share Posted September 15, 2008 $Restrict = array('.php', '.com', '.exe', '.bat', '.asp', '.dll', '>', '"', '\''); $Filename = eregi_replace($Restrict,"", $_FILES['uploadedfile']['name']); //Removes the restricted extensions and symbols from the file name, this combats sql injection, scripts, and double extensions print_r($Restrict); ?> I can't seem to get eregi_replace to use my array. Can any one tell me why. Thanks. Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/ Share on other sites More sharing options...
Maq Posted September 15, 2008 Share Posted September 15, 2008 Wild guess but I think because the first parameter of this function takes in a string not an array. So you would have to loop through the array and pass in every string. Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642092 Share on other sites More sharing options...
wildteen88 Posted September 15, 2008 Share Posted September 15, 2008 swap eregi_replace with str_replace no point in using eregi replace if you not using regex. Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642096 Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 I think strreplace would work better here... Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642097 Share on other sites More sharing options...
Brian W Posted September 15, 2008 Author Share Posted September 15, 2008 Wild guess but I think because the first parameter of this function takes in a string not an array. So you would have to loop through the array and pass in every string. Possibly, how would I get it to loop through the array? About the str_replace, its case sensitive and I can't seem to use stri_replace with my version of php or something. Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642099 Share on other sites More sharing options...
wildteen88 Posted September 15, 2008 Share Posted September 15, 2008 eregi_replace should still be able to take an array. Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642100 Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 so lowercase the other string: $Filename = strtolower($_FILES['uploadedfile']['name']); $Filename = str_replace($Restrict,"", $Filename); eregi_replace() takes strings only Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642103 Share on other sites More sharing options...
Brian W Posted September 15, 2008 Author Share Posted September 15, 2008 Thank you much Mchl. That worked for me... good to know eregi_replace only take strings. Also, thanks every one else for the input. so lowercase the other string: $Filename = strtolower($_FILES['uploadedfile']['name']); $Filename = str_replace($Restrict,"", $Filename); eregi_replace() takes strings only Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642108 Share on other sites More sharing options...
Maq Posted September 15, 2008 Share Posted September 15, 2008 FYI to loop through an array do this: foreach($Restrict as $value) { $Filename = eregi_replace($value,"", $_FILES['uploadedfile']['name']); echo $value; } Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642114 Share on other sites More sharing options...
Brian W Posted September 15, 2008 Author Share Posted September 15, 2008 oh, thats cool... might help in the future as I learn to build more and more complex applications. Thanks Maq Link to comment https://forums.phpfreaks.com/topic/124339-solved-array-issue-probly-simple/#findComment-642118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.