Jump to content

preg_replace unknown modifier (php noob)


kanjigirl

Recommended Posts

I have a form that includes this snippet of code that rewrites the filename for an image to be uploaded:

 

foreach ($images as $image) {
        $sfname = preg_replace('/[^a-zA-Z]/','',$_POST['fname']);
        $new_name = $sfname[0] . '_' . preg_replace('/[^a-zA-Z]/','',$_POST['lname']) . '_' . $id . '-' . ($i + 1) . '.' . $extensions[$i];
        move_uploaded_file($_FILES[$image]['tmp_name'],$IMAGE_DIR . $new_name);
        $file = fopen($IMAGE_DIR . $new_name,"r");

 

A user keeps getting the message "Warning: preg_replace() [function.preg-replace]: Unknown modifier '4' in

/home/fcmoca/public_html/studiotour/process-entry.php on line 317"  whenever he tries to submit. His .jpg file has spaces and a hyphen in it, and I thought that might be the problem, but I tried it myself with his file and it uploaded fine for me. A typical filename would be "Cole Thompson - Two Trees in Snow.jpg."

 

I'm new to PHP and have no clue why I would be able to upload his information but he can't. Can someone help me?

Link to comment
https://forums.phpfreaks.com/topic/44556-preg_replace-unknown-modifier-php-noob/
Share on other sites

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.