upload images - preg_replace
I am using the statement below to clean up an image file name before it's uploaded. I seem to be getting an occasional server error an my images are sometimes pixelated. I don't know whether it's my code or the server that causing the problem. What's the best way to rename the uploaded file?
Renaming code at the top of the page:
------------------------------------------------------
if(isset($_FILES['item_photo']['name'])) {
$_FILES['item_photo']['name'] = preg_replace('/[^A-Za-z0-9.]/','_',$_FILES['item_photo']['name']);
}