kanjigirl Posted March 27, 2007 Share Posted March 27, 2007 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 More sharing options...
notepad Posted March 28, 2007 Share Posted March 28, 2007 It sounds like it might be a problem with his computer, since you can do it and he can't... Whats the link? I can test it for you too. Link to comment https://forums.phpfreaks.com/topic/44556-preg_replace-unknown-modifier-php-noob/#findComment-216465 Share on other sites More sharing options...
effigy Posted March 28, 2007 Share Posted March 28, 2007 Sounds like a delimiter problem, which I don't see. Where's line 317? Are there any other regexes in the code? Link to comment https://forums.phpfreaks.com/topic/44556-preg_replace-unknown-modifier-php-noob/#findComment-216762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.