I'd guess your problem is with the line
$file_to_attach="/".$uploaddir.$_FILES['file']['name'];
Everywhere else you use
$uploaddir
as a relative directory (relative to your document root, presumably), but here you are making it an absolute path with the leading
/
.
Peter