file 相关问题

可通过基于字符串的名称或路径访问的任意信息块或用于存储信息的资源。文件可用于计算机程序,通常基于某种持久存储。

去;包:命令行参数 golang.org/x/net/websocket 导入循环

我正在尝试设置 noVNC-audio-master 运行需要 [go],然后要求您为 websocket 创建一个 go.mod 文件 但是,运行命令后,这是输出: 用户@设备:~/向下...

回答 1 投票 0

公共文件夹内的静态文件在 PHP MVC 架构中不起作用

我的项目结构 核 路由器.php http 控制器 索引.php 民众 CSS js 图像 索引.php 意见 路线.php 索引.php代码 我的项目结构 核心 路由器.php http 控制器 index.php 公众 CSS js img index.php 浏览量 routes.php index.php代码 <?php use Core\Router; const BASE_PATH = __DIR__.'/../'; session_start(); require BASE_PATH.'vendor/autoload.php'; require BASE_PATH.'Core/functions.php'; require BASE_PATH.'bootstrap.php'; $router = new Router(); require BASE_PATH.'routes.php'; $uri = parse_url($_SERVER['REQUEST_URI'])['path']; $method = $_POST['_method'] ?? $_SERVER['REQUEST_METHOD']; try { $router->route($uri, $method); } catch (Exception $e) { echo $e->getMessage(); } Router.php代码 <?php namespace Core; use Core\Middleware\Middleware; use Exception; use JetBrains\PhpStorm\NoReturn; class Router { protected array $routes = []; public function get($uri, $controller): void { $this->add('GET', $uri, $controller); } public function add($method, $uri, $controller): static { $this->routes[] = [ 'uri' => $uri, 'controller' => $controller, 'method' => $method, 'middleware' => null ]; return $this; } public function post($uri, $controller): void { $this->add('POST', $uri, $controller); } public function delete($uri, $controller): static { return $this->add('DELETE', $uri, $controller); } public function patch($uri, $controller): static { return $this->add('PATCH', $uri, $controller); } public function put($uri, $controller): static { return $this->add('PUT', $uri, $controller); } public function only($key): static { $this->routes[array_key_last($this->routes)]['middleware'] = $key; return $this; } /** * @throws Exception */ public function route($uri, $method) { foreach ($this->routes as $route) { if ($route['uri'] === $uri && $route['method'] === strtoupper($method)) { Middleware::resolve($route['middleware']); return require base_path('Http/controllers/'.$route['controller']); } } $this->abort(); } #[NoReturn] protected function abort($code = 404): void { http_response_code($code); require base_path("views/{$code}.php"); die(); } public function previousUrl() { return $_SERVER['HTTP_REFERER']; } } routes.php代码 <?php /** @var Router $router */ use Core\Router; $router->get('/', 'index.php'); $router->get('/contact', 'contact.php'); $router->get('/about', 'about.php'); $router->get('/service', 'service.php'); $router->get('/menu', 'menu.php'); $router->get('/team', 'team.php'); $router->get('/testimonial', 'testimonial.php'); $router->get('/booking', 'booking/booking.php'); $router->get('/register', 'register/create.php'); $router->get('/login', 'session/create.php'); $router->get('/cart', 'cart/index.php'); 公共文件夹中存在的所有静态文件和库,当我调用它们时,它们在项目中的其他页面上不起作用。 我使用 php -S lcoalhost:8080 在公共文件夹中运行项目。 我尝试更改静态文件的路径,但它不起作用,我也尝试将 .htaccess 添加到项目中,但也不起作用 那是因为 PHP 的内置“服务器”并不是真正的服务器(因为缺乏更好的描述)。您应该学习如何使用 Docker 设置 nginx/FPM 服务器。 但是,短期内,您可以创建一个单独的文件,在针对 index.php 运行之前尝试加载现有文件。 您将服务器初始化命令更改为: php -S 127.0.0.1:8080 ./public/built-in.php 这有点像在这个练习中(有点过时了,但它应该解释了这个想法)。

回答 1 投票 0

公共文件夹内的静态文件在 PHP MVC 架构中不起作用

我的项目结构 核 路由器.php http 控制器 索引.php 民众 CSS js 图像 索引.php 意见 路线.php 索引.php代码 我的项目结构 核心 路由器.php http 控制器 index.php 公众 CSS js img index.php 浏览量 routes.php index.php代码 <?php use Core\Router; const BASE_PATH = __DIR__.'/../'; session_start(); require BASE_PATH.'vendor/autoload.php'; require BASE_PATH.'Core/functions.php'; require BASE_PATH.'bootstrap.php'; $router = new Router(); require BASE_PATH.'routes.php'; $uri = parse_url($_SERVER['REQUEST_URI'])['path']; $method = $_POST['_method'] ?? $_SERVER['REQUEST_METHOD']; try { $router->route($uri, $method); } catch (Exception $e) { echo $e->getMessage(); } Router.php代码 <?php namespace Core; use Core\Middleware\Middleware; use Exception; use JetBrains\PhpStorm\NoReturn; class Router { protected array $routes = []; public function get($uri, $controller): void { $this->add('GET', $uri, $controller); } public function add($method, $uri, $controller): static { $this->routes[] = [ 'uri' => $uri, 'controller' => $controller, 'method' => $method, 'middleware' => null ]; return $this; } public function post($uri, $controller): void { $this->add('POST', $uri, $controller); } public function delete($uri, $controller): static { return $this->add('DELETE', $uri, $controller); } public function patch($uri, $controller): static { return $this->add('PATCH', $uri, $controller); } public function put($uri, $controller): static { return $this->add('PUT', $uri, $controller); } public function only($key): static { $this->routes[array_key_last($this->routes)]['middleware'] = $key; return $this; } /** * @throws Exception */ public function route($uri, $method) { foreach ($this->routes as $route) { if ($route['uri'] === $uri && $route['method'] === strtoupper($method)) { Middleware::resolve($route['middleware']); return require base_path('Http/controllers/'.$route['controller']); } } $this->abort(); } #[NoReturn] protected function abort($code = 404): void { http_response_code($code); require base_path("views/{$code}.php"); die(); } public function previousUrl() { return $_SERVER['HTTP_REFERER']; } } routes.php代码 <?php /** @var Router $router */ use Core\Router; $router->get('/', 'index.php'); $router->get('/contact', 'contact.php'); $router->get('/about', 'about.php'); $router->get('/service', 'service.php'); $router->get('/menu', 'menu.php'); $router->get('/team', 'team.php'); $router->get('/testimonial', 'testimonial.php'); $router->get('/booking', 'booking/booking.php'); $router->get('/register', 'register/create.php'); $router->get('/login', 'session/create.php'); $router->get('/cart', 'cart/index.php'); 公共文件夹中存在的所有静态文件和库,当我调用它们时,它们在项目中的其他页面上不起作用。 我使用 php -S lcoalhost:8080 在公共文件夹中运行项目 我尝试更改静态文件的路径,但它不起作用,我也尝试将 .htaccess 添加到项目中,但也不起作用 那是因为你的 php 内置的“服务器”并不是真正的服务器(因为缺乏更好的描述)。您应该学习如何使用 docker 设置 nginx/fpm 服务器。 但是,简而言之,您可以创建一个单独的文件,在针对 index.php 运行之前尝试加载现有文件。 您将服务器初始化命令更改为: php -S 127.0.0.1:8080 ./public/built-in.php 有点像这个练习(有点过时,但应该解释一下这个想法)。

回答 1 投票 0

Maven/Java 文件存储

我正在使用 Maven 开发一个项目,我有点困惑在这个程序中存储文件以供访问的正确方法是什么? 我看过使用 Maven 资源,但我不是超级

回答 1 投票 0

Python 安装大问题

所以,和很多人一样,我用 python 编程,而且从来没有遇到过任何问题。直到有一天我决定重新安装所有东西,因为当我安装 python 时,我是一个十足的菜鸟......

回答 1 投票 0

无法使用python-docx读取docx文件

我有这个代码: 导入操作系统 导入回溯 导入 pdfplumber 从 docx 导入文档 def read_docx(文件路径): 尝试: doc = 文档(文件路径) 内容 = [段落.文本

回答 1 投票 0

os.path.isfile() 返回 False。这可能是什么原因造成的?

嗨,我正在尝试使用以下代码读入并显示带有 cv2 的图片以进行进一步分析: 编辑:我添加了清晰的用户名路径,以证明它不包含古怪的字符...

回答 2 投票 0

Python file.save 保存空文件

我从前端上传检索文件,并以这种方式转换文件的哈希值: blob_file = Convert_to_blob(文件) 有了这个功能: def Convert_to_blob(文件: file_storage.FileStorage) ->...

回答 1 投票 0

c++ 通过解析和排序数字来创建文本文件

`美好的一天,我正在为学校制作一个程序(简单)。它收到一个包含 200 万个数字的文本文件,然后必须使用 bubble 方法对它们进行排序,并且必须在其中创建一个文本文件

回答 1 投票 0

PHP:检查文件是否直接加载而不是包含?

有没有办法阻止用户查看文件但仍将其用作包含在 PHP 中的另一个文件中?

回答 15 投票 0

如何创建不闪烁的下载链接?

我希望用户能够通过我在控制器中设置的方法下载文件。此外,我不希望当用户下载文件时浏览器中的 URL 发生更改。我有这个林...

回答 5 投票 0

Java DocumentFilter 问题

我遇到了 DocumentFilter 的问题(或者至少看起来这就是导致问题的原因)。 代码本身从文件夹中获取文件,然后允许我重命名它们,这是我所困扰的部分......

回答 1 投票 0

Curl - 文件格式问题:Linux 与 Windows

我在Linux中有以下.dat文件: U|205003509999|PMBA文章2|02000000|02000000|3|PM|F。 AJDJDJ|K|00000.0000|K|1|00000002|10999|3500002|||||0|0||00000.0000|150| 它是一个平面文件,由...组成

回答 1 投票 0

VS Code 导航到文件资源管理器树顶部

请原谅,如果这个问题已在其他地方得到回答,但我似乎无法找到一个快速而简单的解决方案来解决我认为是一个非常基本的问题! 那么,我必须使用什么键盘快捷键才能跳转到...

回答 1 投票 0

在 Rust 中使用 std::fs::read_dir 作为迭代器

我是 Rust 新手(大约一个月),这是我第一次在这个平台上提问。 请原谅我犯了一些错误。 现在,我正在尝试制作一个复制

回答 1 投票 0

如何从需要在其自己的文件夹中运行另一个包的包中导入文件

振兴/ ├── 应用程序.py ├── 静态/ ├── 模板/ ├── GFPGAN/ │ ├── 实验/ │ ├── gfpgan/ │ ├── 输入/ │ ├── 结果/ │ └── inference_gfpgan.py └── 去旧化/ ├── 脱老/ ├──

回答 1 投票 0

使用模板更新所有文件不起作用(PHP)(已修复)

我下面的代码正在尝试更新目录 /c/sl/* 中的一堆聊天服务器。我在那里有两个文件,它们都有一个带有服务器信息的 $_SESSION 变量。现在,我正在尝试...

回答 1 投票 0

我的 django 项目中的 Views.py 中出现 ImportError

我试图从几个月前制作的项目中导入函数,但出现此错误:ModuleNotFoundError:没有名为“seleniumtrack”的模块 我尝试了一些 ChatGPT 推荐的东西...

回答 1 投票 0

iOS:如何写入项目中特定目录下的文件?

我正在尝试将我在应用程序中收集的一些字符串输出到文本文件中。 文本文件将始终存在于我的项目中,如下所示: 我正在尝试用新的(多

回答 3 投票 0

应使用哪个“cacerts”来更新 Java 安全文件?

我即将更新/添加 Java 证书到 MacOS 中的证书列表。 为了知道要添加到哪个“cacerts”文件 - 运行以下命令: sudo find / -iname "*cacerts*" 2> /dev/null

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.