+ $user_comp = user_company();
+ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
+ {
+ $result = $_FILES['pic']['error'];
+ $filename = $comp_path . "/$user_comp/images";
+ if (!file_exists($filename))
+ {
+ mkdir($filename);
+ }
+ $filename .= "/".$_FILES['pic']['name'];
+
+ //But check for the worst
+ if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
+ {
+ display_notification(_('Only jpg files are supported - a file extension of .jpg is expected'));
+ $input_error = 1;
+ }
+ elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024))
+ { //File Size Check
+ display_notification(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
+ $input_error = 1;
+ }
+ elseif ( $_FILES['pic']['type'] == "text/plain" )
+ { //File type Check
+ display_notification( _('Only graphics files can be uploaded'));
+ $input_error = 1;
+ }
+ elseif (file_exists($filename))
+ {
+ display_notification(_('Attempting to overwrite an existing item image'));
+ $result = unlink($filename);
+ if (!$result)
+ {
+ display_error(_('The existing image could not be removed'));
+ $input_error = 1;
+ }
+ }
+
+ if ($input_error != 1)
+ {
+ $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
+ $_POST['coy_logo'] = $_FILES['pic']['name'];
+ $message = ($result)?_('File url') ."<a href='$filename'>$filename</a>" : "Somthing is wrong with uploading a file.";
+ }
+ /* EOF Add Image upload for New Item - by Ori */
+ }
+