如何使用 php 实现 OF 文件选择器?

发布于 2025-01-03 06:21:55 字数 57 浏览 1 评论 0原文

我需要用 php 实现一个操作系统文件选择器,但我不知道如何去做。 有人可以引导我走向正确的方向吗?

I need to implement an OS file chooser with php but I don't know how to go about doing this.
Can somebody guide me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半寸时光 2025-01-10 06:21:55

这是一个基本的文件选择表格。

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

这是处理表单的基本 php。

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }

您可以在这里阅读更多内容。

http://www.w3schools.com/php/php_file_upload.asp

This is a basic file choosing form.

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

This is the basic php to handle the form.

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }

You can read more here.

http://www.w3schools.com/php/php_file_upload.asp

人心善变 2025-01-10 06:21:55

如果您使用 php 驱动桌面应用程序,请使用 UI 工具包的方法,例如 GTKFileChooser

如果您使用 php 提供网页服务,请注意,服务器只能将 HTML 和 JavaScript 发送到客户端,而不能本机打开网页。在 HTML 代码中使用 元素:

<form enctype="multipart/form-data" action="your-script.php" method="POST">
<input type="file" name="file" />
<input type="submit" />
</form>

您可以使用 提交方法。如果您将整个表单放入 iframe 中,您可以执行以下操作:所以在后台。

有关输入字段的详细信息,请参阅 HTML5 标准。有关提交表单后如何处理文件的信息,请查看 PHP 手册

If you're using php to drive a desktop application, use the method of your UI toolkit, such as GTKFileChooser.

If you're using php to serve webpages, note that the server can only send HTML and JavaScript to the client, and not natively open webpages. Use an <input> element in your HTML code:

<form enctype="multipart/form-data" action="your-script.php" method="POST">
<input type="file" name="file" />
<input type="submit" />
</form>

You can submit the form automatically from JavaScript with the submit method. If you place the whole form in an iframe, you can do so in the background.

For details on the input field, consult the HTML5 standard. For information on how to handle the file once the form is submitted, have a look at the php manual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文