php files 数组,关于php:文件上传$ _FILES数组为空

我想将文件上传到服务器,但是$_FILES数组似乎为空。

我的以下代码有问题吗?

Bestand(en)

Aangepaste bestandsnaam

PHP代码

if(isset($_POST['fotos_toevoegen'])){

print_r($_FILES['fotos']['name']);

$array_lenght = count($_FILES['fotos']['name']);

//print_r($_FILES['fotos']);

for($i = 0; $i < $array_lenght; $i++){

$array_fotos = array();

// trek $_FILES uit elkaar zodat je individuele foto kan toevoegen.

foreach($_FILES['fotos'] as $key => $value){

$array_fotos[$key] = $_FILES['fotos'][$key][$i];

}

$foto = new Foto();

$foto->path = $path . '/cms/fotos/orginele-bestanden';

$foto->naam = $_POST['naam'].'-'. $i;

$foto->album_id = $session_album_id;

$foto->file_info = $array_fotos;

$foto->width_thumbnail = 300;

$foto->height_thumbnail = 250;

$foto->width_grootformaat = 500;

$foto->height_grootformaat = 400;

$foto->to_string();

//$foto_beheer->add($foto);

}

}

Print_r($ _ FILES ['fotos'])向我展示了这一点:

Array([name] => Array([0] => pannekoeken4.jpg [1] => pannekoeken5.jpg)[type] => Array([0] => [1] =>)[tmp_name] => Array ([0] => [1] =>)[错误] =>数组([0] => 6 [1] => 6)[size] =>数组([0] => 0 [1] => 0))

您是否像if(isset($ _ POST)){echo"

";print_r($_FILES);echo"

";}一样打印?

为什么动作是空的?

请也添加您的PHP代码。

@ Bhumi Shah是,我做过id,我做了print_r($ _ FILES),就是我发现它是空的。

将操作留为空白会使您返回同一页面(我知道这不是一个好习惯)

您能否对照为post_max_size配置的值检查上传的文件的大小

如果发布数据的大小大于post_max_size,则$ _POST和$ _FILES超全局变量为空。

请参考以下网址

点击这里

一些非常基本的测试给了我以下结果:

if(isset($_POST)){

echo '[cc lang="php"]';

var_dump($_POST);

var_dump($_FILES);

echo '

';

}

?>

Bestand(zh)

td>td>

tr>

Aangepaste bestandsnaam td>td>

tr>

td>td>

tr>

table>

form>

code> pre>

输出:

array(2) {

["naam"]=>

string(17)"customfilename"

["fotos_toevoegen"]=>

string(15)"Fotos toevoegen"

}

array(1) {

["fotos"]=>

array(5) {

["name"]=>

array(1) {

[0]=>

string(50)"2014-10-06.pdf"

}

["type"]=>

array(1) {

[0]=>

string(15)"application/pdf"

}

["tmp_name"]=>

array(1) {

[0]=>

string(36)"/Applications/MAMP/tmp/php/php79bugX"

}

["error"]=>

array(1) {

[0]=>

int(0)

}

["size"]=>

array(1) {

[0]=>

int(770241)

}

}

}

是的,但是那不是我的服务器上正在发生的事情,是否可能不是我的代码而是某些服务器设置?

您已经检查过此帖子了吗? stackoverflow.com/questions/3586919/

病出来看看! 如果找到解决方案,请在此处发布。

Copyright ©  码农家园

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值