Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.