【问题标题】:How to edit htacess file to support file upload如何编辑 htaccess 文件以支持文件上传
【发布时间】:2013-02-06 03:06:36
【问题描述】:

我有一个用 php 编写的示例图片上传代码。 ios 开发人员调用 Web 服务。文件上传在一台服务器上运行良好,但在另一台服务器上上传失败。

检查权限、目录列表等。在尝试上传图片时,服务器会抛出 500 内部错误。

我认为 .htaccess 可能存在问题

谁能指导我编辑htaccess,使其支持图片上传。

谢谢。 通过浏览器上传时,文件上传工作正常。它没有返回任何错误

这是错误日志 PHP 警告:fopen(xml/) [function.fopen]:无法打开流:第 271 行的 /home/appsimon/public_html/api/import.php 中没有这样的文件或目录

实际上它在这台服务器上工作到上周。突然文件上传失败

htaccess 中的代码

#old php Handler
#deny from all 
#allow from ip address

只有这 3 行注释 来自应用控制台的错误

    <Warning>: aResponse:<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <html><head>
 <title>500 Internal Server Error</title>
 </head><body>
 <h1>Internal Server Error</h1>
 <p>The server encountered an internal error or
 misconfiguration and was unable to complete
 your request.</p>
 <p>Please contact the server administrator,
  webmaster@appsimon.com and inform them of the time the error occurred,
 and anything you might have done that may have
 caused the error.</p>
 <p>More information about this error may be available
 in the server error log.</p>
 <p>Additionally, a 500 Internal Server Error
 error was encountered while trying to use an ErrorDocument to handle the request.</p>
 </body></html>
Feb  6 00:30:48 Varmas-iPhone SNMC[1944] <Warning>: -JSONValue failed. Error trace is: (
     "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x541a40 {NSLocalizedDescription=Unrecognised leading character}"
 )
Feb  6 00:30:49 Varmas-iPhone SNMC[1944] <Warning>: fail

【问题讨论】:

  • 您的错误日志中有什么内容?
  • 显示您的 htaccess,因为错误 500 可能意味着您的 htaccess 中有错误。
  • htaccess 文件中没有任何内容,所有内容均已注释。它是一个 linux 服务器
  • @John 我用错误日志更新了我的问题,请仔细阅读
  • 不,不会,那只是一个 php 警告,不会引发 500(但它告诉您目录不存在,您可能想查看它)。也许您可以显示 htaccess 文件中的内容,并显示 apache 错误日志。

标签: php .htaccess file-upload webserver


【解决方案1】:

在您的 htaccess 中尝试添加这些值,看看会发生什么

php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 180
php_value max_input_time 180

根据需要调整值

【讨论】:

  • 请检查我编辑的问题以获取回复。和之前一样
  • 我发送的文件是50kb
猜你喜欢
  • 2021-10-07
  • 1970-01-01
  • 2012-07-02
  • 2010-10-09
  • 1970-01-01
  • 2019-11-28
  • 2017-04-11
  • 2012-04-15
  • 2017-03-28
相关资源
最近更新 更多