<?php function img_upload($photo,$photo_name,$tmp_photo,$uploaddir,$photo_id,$paramiter,$redirect_url) { if (!$photo) { $photo = $tmp_photo; } else { $ext = explode(".",$photo_name); if (strtoupper($ext[1]) == "JPG" || strtoupper($ext[1]) == "JPEG") { $final_filename = $photo_id . $paramiter .".jpg"; $newfile = $uploaddir ."$final_filename"; if (is_uploaded_file($photo)) { if (!copy($photo,"$newfile")) { print "Error Uploading File."; exit(); } } $photo = $final_filename; if ($tmp_photo) { unlink($uploaddir . $tmp_photo); } } else { echo "<meta http-equiv=\"refresh\" content=\"0; url = '". $redirect_url ."'\" >"; exit; } } return $photo; } ?>