php 上传错误1,php文件上传错误1 – 使用php_ini的正确方法是什么?

我在将pdf上传到我的服务器时遇到问题. upload_max_filesize是2M,文件大于4M.我在这里发现了一个类似问题的帖子

我可以从php.net收集正确使用ini_set命令的是这个,我目前正在使用它.

ini_set('upload_max_filesize', 100000000);

ini_set('post_max_size', 110000000);

ini_set('memory_limit', 120000000);

ini_set('max_input_time', 20);

但在我发布的链接中,似乎他们正在使用不同的方法(如果它们不只是总结正确的代码).但似乎我的代码也没有正常工作.我有在我的页面底部,它说upload_max_filesize仍然是2M.我是否使用了ini_set的正确语法?或者我的问题是上传我的pdf别的东西? 处理上传的代码是

//======================pdf upload=====================

if ($_POST['erasePDF'] == "Yes") //checking if erase box was checked and erasing if true

{

if (file_exists($pdf))

{

unlink( $pdf );

$pdf = "";

}

}

print_r($_FILES['pdf']);

if (!empty($_FILES['pdf']['name'])) //checking if file upload box contains a value

{

$saveDirectoryPDF = 'pdfs/'; //name of folder to upload to

$tempName = $_FILES['pdf']['tmp_name']; //getting the temp name on server

$pdf = $_FILES['pdf']['name']; //getting file name on users computer

$test = array();

$test = explode(".", $pdf);

if((count($test) > 2) || ($test[1] != "pdf" && $test[1] != "doc" && $test[1] != "docx")){

echo "invalid file";

}else{

$count = 1;

do{

$location = $saveDirectoryPDF . $count . $pdf;

$count++;

}while(is_file($location));

if (move_uploaded_file($tempName, $location)) //Moves the temp file on server

{ //to directory with real name

$pdf = $location;

}

else

{

echo "hi";

echo '

There was an error while uploading the file.

';

}

}

}else{

$pdf = "";

}

if(isset($_POST['link']) && $_POST['link'] != ""){

$pdf = $_POST['link'];

}

//======================end of pdf upload==============

行’print_r($_ FILES [‘pdf’]);’的输出是

Array ( [name] => takeoutmenu.pdf [type] => [tmp_name] => [error] => 1 [size] => 0 )

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值