"; $res = doesFileUrlExists($url); if ($res[0]) { echo "file exists
"; } else { echo "file NOT exists
"; $extension = pathinfo($file, PATHINFO_EXTENSION); $contType = "application/octet-stream"; if ($extension) { $extension = strtolower($extension); } if ($extension === "doc") { $contType = "application/msword"; } if ($extension === "html") { $contType = "text/html"; } if ($extension === "docx") { $contType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } if ($extension === "xls") { $contType = "application/vnd.ms-excel"; } if ($extension === "xlsx") { $contType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if ($extension === "pdf") { $contType = "application/pdf"; } if ($extension === "jpeg" || $extension === "jpg") { $contType = "image/jpeg"; } if ($extension === "gif") { $contType = "image/gif"; } if ($extension === "png") { $contType = "image/png"; } if ($extension === "mp3") { $contType = "audio/mpeg"; } if ($extension === "zip") { $contType = "application/zip"; } if ($extension === "rar") { $contType = "application/vnd.rar"; } $new_path = str_replace("https://uf.joywork.ru", "", $url); echo $contType . "
"; echo $new_path . "
"; SelectelApi::uploadUserFile($token, $file, $new_path, $contType); } } } } function doesFileUrlExists($url) { $headers = get_headers($url, true); return [(stripos($headers[0], "200 OK") ? true : false), (isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0)]; }