Jump to content

[SOLVED] array issue, probly simple


Brian W

Recommended Posts

$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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.