file 相关问题

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

如何将图像、Pdf 和少量参数从 Angular 一起发送到 Node.Js 服务器

我正在使用 Angular Material 来获取可拖动图像的位置,从用户获取输入类型文件(pdf)以及存储在 ./assets/emojis/ 中的图像。我可以使用...将 Pdf 从 Angular 发送到 Node

回答 2 投票 0

从完整文件路径查找文件名

有没有一种方法可以从文件完整路径(文件路径的一部分)中提取文件名,而无需操作字符串的麻烦? Java 中的等价物是: 文件 f = 新文件 ("C:/some_dir/a...

回答 5 投票 0

SQLite DB 文件句柄永远不会关闭 C#

我正在尝试从我的 C# 应用程序中删除 SQLite 数据库文件。同一应用程序通过每次创建和处置一个新连接来对数据库执行多个 RW 查询。 当尝试

回答 2 投票 0

如何将文件挂载到kubernetes中的helm subchart pod文件系统中?

问题是向第三方开发的 helm subchart 描述的 Kubernetes pod 添加一个包含配置数据的文件。 我读过很多评论说这个问题可以通过引入

回答 1 投票 0

Python 带变量的三引号字符串[重复]

尝试写入带有变量的文件,但返回错误: template = """第一个标题行 第二标题行 房间里还有人 和 %s ”“” 以 open('test','w') 作为我的文件:

回答 3 投票 0

PyCharm 文件大小超出配置限制 (2,56 MB),代码洞察功能不可用

我正在处理一些大的 txt 文件(有些大约 3 GB),每当我必须检查 txt 文件时,都会显示消息“文件大小超出配置的限制(2.56 MB),代码洞察功能不可用&

回答 1 投票 0

如何实现Pythonic行续读

我正在尝试实现一个Python脚本来从ASCII文本文件中读取和提取行。这似乎是一件相当容易的事情,但是我最终遇到了一个我自己无法解决的问题。 ...

回答 2 投票 0

Google Cloud Storage 中每个文件夹的最大文件数

我想将 Google Cloud Storage 设置为我的数据湖,并且我正在使用 Pubsub + 数据流将交互保存到其中。 Dataflow 每 5 分钟创建一个新文件,并将其存储在 GCS 文件夹中。这甚至会...

回答 2 投票 0

如何检查文件是否通过其他进程或应用程序(Windows)被锁定

我正在通过应用程序将文件从 Windows 共享移动到 ftp 服务器。我只是想确保确实没有其他应用程序也尝试处理该文件。我试过你...

回答 2 投票 0

清除和删除文件之间的区别?

我查了一下,但没能发现清除和删除一组文件之间有很多区别。除了简单的备份和删除之外,还需要清除吗? 编辑:具体来说,这是一个...

回答 4 投票 0

使用cmd删除隐藏文件和普通文件

以下行递归仅删除扩展名为 .mta 的隐藏文件 德尔 /S /A:H *.mta 我想要做的是,同时删除:带有 .mta 扩展名的隐藏文件和普通文件。哈...

回答 3 投票 0

Multer 未上传文件

我正在尝试使用 multer 将文件从客户端的 html 表单上传到服务器端,multer 模块在服务器端处理该文件。 这里的事情是一切都好,

回答 3 投票 0

如何用 die() 包含文件;功能?

file1.php 和 file2.php 带有 die();功能。 包含.php: 文件1.php 文件2.php file1.php 和 file2.php 带有 die();功能。 include.php: <? include 'file1.php'; include 'file2.php' ?> 文件1.php <? echo 'included'; die(); ?> 文件2.php <? echo 'not included'; die(); ?> 如何使用 die() 包含这两个文件;功能? 如果你想测试include行是否成功,你可以测试include函数本身的返回值: // https://www.php.net/manual/en/function.include.php Example #4 if ((include 'file1.php') != 'OK') { die(); } 您也可以根据您的需要考虑使用 require() 而不是 include() : require() 与 include() 相同,除了失败时它也会产生致命的 E_ERROR 级别错误。换句话说,它将停止脚本,而 include() 仅发出警告 (E_WARNING),允许脚本继续。 如果我正确理解你想要做什么,那么不幸的是这是不可能的。 die(); 将停止脚本在调用它的地方执行。 以下是如何包含文件,或者如果包含失败则显示一条消息的代码示例。 (include('file.php')) || die('Failed to include file!'); if (!condition){ include_once('./inc/header.inc.php'); echo "Errormessage"; include_once('./inc/footer.inc.php'); die(); } 我希望这是你想要的。 只是对 LorenzoP 方法的一个小改进: (@include("file.php")) or die("Failed to include!"); // notice the @ sign! 这样,当包含失败时,您就可以节省 2 行难看的 php 警告。否则我认为这确实是处理失败包含的最佳方法。 (另外,他的答案应该是被接受的。) 如果你的包含文件的执行不依赖于当前文件(没有共享变量、函数等),那么使用 file_get_contents('link_to_file.php'); 而不是包含方法。当你强制文件独立执行时,它不会对脚本执行产生影响。 die() 只是一个有错误的退出,你不能在其中包含文件,我真的不明白你为什么要这样做。您能否提供更多关于您想要实现的目标的详细信息?

回答 7 投票 0

Python 特殊字符未保留在写入“wb”的文件中

我在以下函数中遇到问题: def download_zip(key: str): response = requests.get('某个网址') 如果响应.status_code == 200: header = response.headers.get('co...

回答 1 投票 0

去;包:命令行参数 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

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