0){ $path = $_SERVER['DOCUMENT_ROOT']."/upload/reqs/".$req_id; $name = md5($_FILES['file']['name'].$_FILES['file']['size']."reqs".$req_id.time()); } else if ($object_id > 0){ $path = $_SERVER['DOCUMENT_ROOT']."/upload/objects/".$object_id; $name = md5($_FILES['file']['name'].$_FILES['file']['size']."objects".$object_id.time()); } $result['guid'] = $name; $result['res'] = 'failed'; if(!file_exists($path)){ mkdir($path, 0777); } $sql = "INSERT INTO clients_files (guid, client_id, type, name, event_id) VALUES ('{$name}', '{$client_id}', '{$type}', '{$_FILES['file']['name']}', '{$_SESSION['event_id_temp']}')"; if($req_id > 0){ $sql = "INSERT INTO clients_files (guid, req_id, type, name, event_id) VALUES ('{$name}', '{$req_id}', '{$type}', '{$_FILES['file']['name']}', '{$_SESSION['event_id_temp']}')"; } else if($object_id > 0){ $sql = "INSERT INTO clients_files (guid, object_id, type, name, event_id) VALUES ('{$name}', '{$object_id}', '{$type}', '{$_FILES['file']['name']}', '{$_SESSION['event_id_temp']}')"; } if(!file_exists($path."/".$name.".".$type)){ if (move_uploaded_file($_FILES["file"]["tmp_name"], $path."/".$name.".".$type)) { mysql_query($sql); if($req_id > 0) { //отпарвляем файл в Селектел $token = SelectelApi::getNewToken(); $contType = "application/octet-stream"; if ($type) { $type = strtolower($type); } if ($type === "doc") { $contType = "application/msword"; } if ($type === "docx") { $contType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } if ($type === "xls") { $contType = "application/vnd.ms-excel"; } if ($type === "xlsx") { $contType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if ($type === "pdf") { $contType = "application/pdf"; } if ($type === "jpeg" || $type === "jpg") { $contType = "image/jpeg"; } if ($type === "gif") { $contType = "image/gif"; } if ($type === "png") { $contType = "image/png"; } if ($type === "mp3") { $contType = "audio/mpeg"; } if ($type === "zip") { $contType = "application/zip"; } if ($type === "rar") { $contType = "application/vnd.rar"; } $new_path = "/upload/reqs/". $req_id . "/" . $name . '.' . $type; $r = SelectelApi::uploadUserFile($token, $path . "/" . $name . "." . $type, $new_path, $contType); $result['sel'] = $r; } if($object_id > 0) { //отпарвляем файл в Селектел $token = SelectelApi::getNewToken(); $contType = "application/octet-stream"; if ($type) { $type = strtolower($type); } if ($type === "doc") { $contType = "application/msword"; } if ($type === "docx") { $contType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } if ($type === "xls") { $contType = "application/vnd.ms-excel"; } if ($type === "xlsx") { $contType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if ($type === "pdf") { $contType = "application/pdf"; } if ($type === "jpeg" || $type === "jpg") { $contType = "image/jpeg"; } if ($type === "gif") { $contType = "image/gif"; } if ($type === "png") { $contType = "image/png"; } if ($type === "mp3") { $contType = "audio/mpeg"; } if ($type === "zip") { $contType = "application/zip"; } if ($type === "rar") { $contType = "application/vnd.rar"; } $new_path = "/upload/objects/". $object_id . "/" . $name . '.' . $type; $r = SelectelApi::uploadUserFile($token, $path . "/" . $name . "." . $type, $new_path, $contType); $result['sel'] = $r; } if($client_id > 0) { //отпарвляем файл в Селектел $token = SelectelApi::getNewToken(); $contType = "application/octet-stream"; if ($type) { $type = strtolower($type); } if ($type === "doc") { $contType = "application/msword"; } if ($type === "docx") { $contType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } if ($type === "xls") { $contType = "application/vnd.ms-excel"; } if ($type === "xlsx") { $contType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if ($type === "pdf") { $contType = "application/pdf"; } if ($type === "jpeg" || $type === "jpg") { $contType = "image/jpeg"; } if ($type === "gif") { $contType = "image/gif"; } if ($type === "png") { $contType = "image/png"; } if ($type === "mp3") { $contType = "audio/mpeg"; } if ($type === "zip") { $contType = "application/zip"; } if ($type === "rar") { $contType = "application/vnd.rar"; } $new_path = "/upload/clients/". $client_id . "/" . $name . '.' . $type; $r = SelectelApi::uploadUserFile($token, $path . "/" . $name . "." . $type, $new_path, $contType); $result['sel'] = $r; } $result['res'] = "done"; echo json_encode($result); exit; } } else { mysql_query($sql); $result['res'] = "done"; echo json_encode($result); exit; } exit(); }