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
Share on other sites

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.