I'm sure there is an easier way to accomplish what I want to do but I'm not working with much php knowledge here. Files are being named by the username but I want to replace any spaces with underscores and strip any special charatcers that may cause a problem when retrieving the uploaded file. I keep trying different things (ex. preg_replace) but I cant figure out how to get it to actually work. This is the function that changes the name of the file, if someone could give me a clue that would be great. It almost looks like the time should be added into the filename but it isnt.
Code: Select all
$file_name = time()."_$image_name";
$pos = strrpos($file_name, '.');
$file_name = substr($file_name, 0,$pos).".jpg";
$file_name = $HTTP_POST_VARS["img_name"].".jpg";