【问题标题】:Can't get file temp name using Wamp Server无法使用 Wamp Server 获取文件临时名称
【发布时间】:2017-08-13 14:18:05
【问题描述】:

我有一个用于上传视频文件的简单表单。文件似乎上传正常,但当我查看目标文件夹时,它不存在。

所以,问题在于移动上传的文件。搜索问题可能出在哪里,我试图捕捉 $_FILES 的名称和临时名称的值,我发现临时名称没有设置。所以,在我的 PHP 代码中:

$videoName     = $_FILES['file']['name'];
$videoTempName = $_FILES['file']['tmp_name'];

$response['videoName'] = $videoName; // OK,it returns "video.mp4" wich is the name of my example file.
$response['videoTempName'] = $videoTempName; // Here is my problem

echo json_encode($response);

您应该知道的一件重要事情是我在 Windows 10 中使用 WAMP 服务器。我怀疑问题出在那儿,因为我在远程服务器中使用了相同的代码而没有错误。

【问题讨论】:

  • 你检查过$_FILES['file']['error']吗?
  • 您上传的文件有可能大于upload_max_filesize(在php.ini 中)
  • @Andreas,没有机会。我的示例视频的文件大小小于 3 MB,WAMP 服务器 post_max_size 设置为 256 MB
  • 您仍应检查错误参数以查看是否发生了其他情况。

标签: php file-upload wampserver


【解决方案1】:

我的错! 我检查了post_max_size,但没有检查设置为 2 MB 的upload_max_filesize,我的文件示例大于此。因此,我在 WAMP Server 的 PHP 配置中将 upload_max_filesize 属性更改为 256 MB,问题就解决了。谢谢安德烈亚斯!

【讨论】:

    猜你喜欢
    • 2013-07-13
    • 2019-12-24
    • 2020-02-16
    • 2012-07-05
    • 2019-01-11
    • 2020-01-19
    • 1970-01-01
    • 2010-11-18
    • 2013-11-05
    相关资源
    最近更新 更多