【问题标题】:HTTP Error 500.50 after upload a file in laravel on IIS在 IIS 上的 laravel 中上传文件后 HTTP 错误 500.50
【发布时间】:2015-06-27 01:43:56
【问题描述】:

我在 php/laravel 中进行文件上传。文件进入public/uploads 目录。

但是,如果我访问 URL testlocal/site/public/uploads/files.pdf 上的文件,我会收到此错误:

HTTP-Error 500.50 - URL Rewrite Module Error.

但是,如果我将此文件从普通 Windows 资源管理器复制到 public/uploads 目录,它可以工作:|

我的网络配置

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
      <rewrite>
          <rules>
              <rule name="Imported Rule 1" stopProcessing="true">
                  <match url="^" ignoreCase="false" />
                  <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                  </conditions>
                  <action type="Rewrite" url="index.php" />
              </rule>
          </rules>
      </rewrite>
  </system.webServer>

还有我的文件上传

if (Input::hasFile('file')) {

    $file = Input::file("file");
    $size = $file->getSize();

    $originalName = $file->getClientOriginalName();
    $fileName = time() . "-" . str_random(5);
    $extension = $file->getClientOriginalExtension();

    if($file->move(__DIR__ . '/../../../public/uploads/', $fileName . "." . $extension)) {
      $upload = new Upload();
      // ...
      $upload->save();

      $answer = array( 'answer' => 'File transfer completed' );
      $json = json_encode( $answer );

      echo $json;
    }

错误代码:0x80070005

// 编辑:好的,如果我给他们文件everyone 访问权限,它可以工作......但是我怎样才能让它自动化呢?

【问题讨论】:

    标签: php laravel iis upload


    【解决方案1】:

    完成这项工作的更好、更强大的方法是创建一个全新的文件夹供 PHP 使用,而不是 C:\Windows\Temp。如果您吸取了教训,您已经知道应该避免将其放入系统控制的文件夹中,以避免任何不必要的继承。只需创建类似 C:\php\upload_dir\ 的内容,然后添加您需要的 IUSR 和 IIS_IUSRS 权限。还要记得相应地更改 php.ini 文件。

    参考:https://www.ryadel.com/en/php-how-to-fix-error-500-on-uploaded-images-and-files/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-02
      • 2016-08-15
      • 1970-01-01
      • 2017-01-11
      • 2017-07-29
      • 1970-01-01
      • 2011-05-04
      • 1970-01-01
      相关资源
      最近更新 更多