Hello all - I'm tweaking a file upload script that I've written that is working, but the server is being a bit tweaky and I want to tighten the code just a little more. Basically, the user can upload a jpg image with any name at all - including special characters ( © ), which I want to strip. However, I need to leave the period before the file extension. I know I could just append a ".jpg" to the back of every image, but that'll leave me with filenames like "myphotojpg.jpg", which just ... I don't know. It bothers me. I'm anal. However, if it's the only way to go then I'll just get over it. This is the code that I'm currently using -

$flName = ereg_replace("[^[:alnum:]]", "", basename($fileArr['name'][$i]));

and it's taking file names like "©myphoto_12.jpg" and giving me "myphotojpg". Which is so derned close to what I want, it makes me hurt. I'm not as up as I should be on regular expressions, so any help here would be greatly appreciated.

    Since you expect the filename to end in .jpg, you could use the [man]basename/man function better by specifying a suffix.

      Been looking at this thing too long by now, and think perhaps I should get away from the computer for a bit. :queasy: Thank you.

        Write a Reply...