【问题标题】:Php song uploadphp歌曲上传
【发布时间】:2012-03-23 18:38:24
【问题描述】:

我正在尝试上传带有 html 表单和 php 代码的歌曲。 我在网上找到了大量脚本,但似乎没有人做这项工作。 我的意思是,它实际上会上传小图像,但是在上传大文件(甚至可以是图像和歌曲)时,它会显示错误 1。 这是我使用的代码:

<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

其他文件:

<?php


$uploaddir = '';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}

print_r($_FILES);

print "</pre>";


?>

问题是,即使我更改 name="MAX_FILE_SIZE" value="" /> 中的值,我也无法上传那些“大”文件。 我已经把php.ini文件中的值改成了20M

【问题讨论】:

  • 听起来像是服务器问题。我们需要更多信息。当您尝试上传歌曲时,服务器日志的输出是什么?可以发一下 move_uploaded_file 的来源吗?
  • 当我尝试上传像歌曲一样的大文件时,它说可能文件上传攻击! Array ( [userfile] => Array ( [name] => DSC_0929.jpg [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) move_uploaded_file 是基本的php函数

标签: php upload


【解决方案1】:

错误信息解释

Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

http://php.net/manual/en/features.file-upload.errors.php

【讨论】:

  • 正如我所说我已经改变了它,但结果没有改变
  • 更改php.ini中的值后是否重启了web服务器?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-02
  • 2011-06-07
  • 1970-01-01
  • 2012-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多