php上传脚本产生大于100 Kb的文件的错误500 [英] php upload script produces error 500 for files larger than 100 Kb

查看:133
本文介绍了php上传脚本产生大于100 Kb的文件的错误500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下php脚本

 <?php 


if ($ _FILES [file] [error]> 0)
{
echo返回码:。 $ _FILES [file] [error]。 < br />;
}
else
{
echoUpload:。 $ _FILES [file] [name]。 < br />;
回显类型:。 $ _FILES [file] [type]。 < br />;
回声大小:。 ($ _FILES [file] [size] / 1024)。 Kb< br />;
回显临时文件:。 $ _FILES [file] [tmp_name]。 < br />;
$ b $ if(file_exists(upload /。$ _FILES [file] [name]))
{
echo $ _FILES [file] [名称] 。 已经存在。 ;


$ $ b $ move_uploaded_file($ _ FILES [file] [tmp_name],
upload /。$ _FILES [file] [名称]);
回声存储在:。 上传/。 $ _FILES [ 文件] [ 名称];
}
}

?>

任何人都可以帮助它上传大于100 Kb左右的pdf文件吗?



我已经检查了我的托管服务提供商,所有的东西都是正确的,我也检查了phpinfo(),其中规定上传到8 Mb应该是允许的



任何人都可以帮助指出我在正确的方向来解决这个问题,我的主机提供商建议我创建一个php.ini文件,但想要命令它需要包含允许上传?



感谢您的帮助

解决方案

以下是您可以用来上传这样一个小技巧大文件使用PHP中的form和move_uploaded_file()函数的文件字段。
$ b 1)在web服务器的根文件夹中创建一个.htaccess文件。



2)把下面的代码放在.htaccess文件的旁边并保存。

  php_value upload_max_filesize 8M 
php_value post_max_size 8M
php_value max_execution_time 200
php_value max_input_time 200

现在您可以将文件大小上传至8MB使用html表单中的文件字段和PHP中提供的move_uploaded_file()函数的简单方法。


I have the following php script

<?php


  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }

?>

can anyone help allow it to upload pdf files larger than around 100 Kb?

I have checked with my hosting provider and everything is correct there, I have also checked phpinfo() which states that uploads to 8 Mb should be allowed

Can anyone help point me in the right direction to fix this, my hosting provider suggested I create a php.ini file, but want commands does it need to contain to allow uploading?

Thanks for your help

解决方案

Here is a small tips for you which you can use to upload such a large file using file field of the form and move_uploaded_file() function in PHP.

1) Create a .htaccess file in the root folder of web server.

2) Put the following code in side the .htaccess file and save it.

php_value upload_max_filesize 8M
php_value post_max_size 8M
php_value max_execution_time 200
php_value max_input_time 200

Now you can upload the file-size up-to 8MB in a simple way using file field in your html form and move_uploaded_file() function available in PHP.

这篇关于php上传脚本产生大于100 Kb的文件的错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆