【问题标题】:Need help in php regarding file post variables.需要有关文件发布变量的 php 帮助。
【发布时间】:2011-10-20 12:22:15
【问题描述】:

大家好,我有 2 个用于文件上传的脚本。

一个是amazon s3上传脚本。使用此脚本,我可以从计算机上传。另一种是普通的远程上传脚本。

我想在 amazon s3 中实现远程上传功能。

这是我在“直接上传脚本”中的代码。

HTML代码

h1>Upload a file</h1>
<p>Please select a file by clicking the 'Browse' button and press 'Upload' to start uploading your file.</p>
    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <input name="theFile" type="file" />
      <input name="Submit" type="submit" value="Upload">
    </form>

获取帖子变量的 PHP 代码

$fileName = $_FILES['theFile']['name'];
$fileTempName = $_FILES['theFile']['tmp_name'];

我的远程上传脚本代码如下。

<form method="POST" action="<?=$self?>">
<input type="text" name="file[]"  size="45" value="">
<input name="submit" type="submit" id="submit" value="submit"></p>
</form>

接收文件的php代码

$files = $_POST['file'];

这是我的问题。如何转换我的远程上传代码

$files = $_POST['file'];

进入

$fileName = $_FILES['theFile']['name']; $fileTempName = $_FILES['theFile']['tmp_name'];

希望你们明白我的意思。谢谢

【问题讨论】:

    标签: php variables file-upload


    【解决方案1】:

    您必须在&lt;form&gt; 标签上设置enctype 参数:

    <form enctype="multipart/form-data" action="__URL__" method="POST">
    

    PHP 手册中有更多帮助:http://www.php.net/manual/en/features.file-upload.post-method.php

    具体看第二个例子。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-04
      • 1970-01-01
      相关资源
      最近更新 更多