Once again I need assistance. I'm trying to rename an Image to a urlencode($name) I'm working with the code below, which works fine sorting the original filename or default.jpg if (empty($image)) { $image = "default.jpg"; } $url = "$image"; $urlinfo = parse_url($url); $filename = basename($urlinfo['path']); $target = $image_path.'/'.$filename; if(file_exists($target) && ! true){ $pathinfo = pathinfo($target); } $fh = fopen($target,'w'); $check = fwrite($fh,file_get_contents($url)); fclose($fh); PHP: If I try anything like $new_filename = urlencode($name); PHP: It will store the file but I'm unable to attach the file .extension .jpg or rather the DOT is ignored $new_filename = urlencode($name)\.jpg; PHP: Could someone show/find me an example of renaming a file with a .image extention ?
That my friend does exactly what I asked, thanks... However it turns out, I don't need to urlencode because a name like Solomon+Kane+%282009%29.jpg Code (markup): wont show for some reason, where as a name like Solomon Kane (2009).jpg Code (markup): will strange ? Thanks again, I wouldn't have got the .'.jpg'; bit, well maybe not so quickly
Try this $reg_ex = "[[:space:]]"; $replace_word = "-"; $newname = ereg_replace($reg_ex, $replace_word, $yourfilename); PHP: