+ $dir = $comp_path."/".user_company(). "/attachments";
+ if (!file_exists($dir))
+ {
+ mkdir ($dir,0777);
+ $index_file = "<?php\nheader(\"Location: ../index.php\");\n?>";
+ $fp = fopen($dir."/index.php", "w");
+ fwrite($fp, $index_file);
+ fclose($fp);
+ }
+ if ($Mode == 'UPDATE_ITEM' && file_exists($dir."/".$_POST['unique_name']))
+ unlink($dir."/".$_POST['unique_name']);
+
+ $unique_name = uniqid('');
+ move_uploaded_file($tmpname, $dir."/".$unique_name);
+ //save the file