replacing HTML string data

From: Date: Thu, 13 Jul 2000 15:16:59 +0000
Subject: replacing HTML string data
Groups: php.general 
Request: Send a blank email to php-general+get-6458@lists.php.net to get a copy of this message
How can I fix the image tags of an html file when it is uploaded? A client uses MS-Word to create newsletters with images and uploads them to the server. Unfortunately, the images often have non-legitimate names (names with spaces, etc.). When she uploads the images my upload script automatically fixes the image names. But, the HTML tags in her newsletter are no longer correct: <img src="bad filename.JPG" width, height, etc.> I can grab the text between the body tags as a string if (file_exists($file)) { $fp = fopen($file,"r"); $contents = fread($fp); fclose($fp); $newstext = ereg_replace(".+<body.*>","",$contents); $newstext = ereg_replace("</body>.+","",$article); } But how do I grab the image names from $newstext to perform replacements on them? I need to replace spaces " " with underlines "_" urlencode the remaining name and make the extension (JPG or GIF) to be all lowercase. Possible? thanks, bill

« previous php.general (#6458) next »