无法加载资源:服务器的响应状态为405(不允许使用方法)

克里斯托弗·彼得森

早上好。

在过去的几天中,我做了很多研究,但似乎仍然无法解决以下错误:

“无法加载资源:服务器响应状态为405(不允许使用方法)http://localhost:35913/Scripts/upload.php

该文件实际上位于此位置,因为如果我转到URL,它将下载PHP文件。

尝试完成使用filedrop.js。需要拖放excel文件并获得昵称的第一列,并将其自动上传到gridview。

upload.php:

<?php
/*!
  FileDrop Revamped - server-side upload handler sample
  in public domain  | http://filedropjs.org

 ***

  This is an example of server-side script that handles both AJAX and IFrame uploads.

  AJAX upload provides raw file data as POST input while IFrame is a POST request
  with $_FILES member set.

  Result is either output as HTML with JavaScript code to invoke the callback
  (like JSONP) or in plain text if none is given (it's usually absent on AJAX).
*/

// If an error causes output to be generated before headers are sent - catch it.
ob_start();

// Callback name is passed if upload happens via iframe, not AJAX (FileAPI).
$callback = &$_REQUEST['fd-callback'];

// Upload data can be POST'ed as raw form data or uploaded via <iframe> and <form>
// using regular multipart/form-data enctype (which is handled by PHP $_FILES).
if (!empty($_FILES['fd-file']) and is_uploaded_file($_FILES['fd-file']['tmp_name'])) {
  // Regular multipart/form-data upload.
  $name = $_FILES['fd-file']['name'];
  $data = file_get_contents($_FILES['fd-file']['tmp_name']);
} else {
  // Raw POST data.
  $name = urldecode(@$_SERVER['HTTP_X_FILE_NAME']);
  $data = file_get_contents("php://input");
}

// Output message for this demo upload. In your real app this would be something
// meaningful for the calling script (that uses FileDrop.js).
$output = sprintf('%s; received %s bytes, CRC32 = %08X, MD5 = %s', $name,
                  number_format(strlen($data)), crc32($data), strtoupper(md5($data)));

// In FileDrop sample this demonstrates the passing of custom ?query variables along
// with an AJAX/iframe upload.
$opt = &$_REQUEST['upload_option'];
isset($opt) and $output .= "\nReceived upload_option with value $opt";

if ($callback) {
  // Callback function given - the caller loads response into a hidden <iframe> so
  // it expects it to be a valid HTML calling this callback function.
  header('Content-Type: text/html; charset=utf-8');

  // Escape output so it remains valid when inserted into a JS 'string'.
  $output = addcslashes($output, "\\\"\0..\x1F");

  // Finally output the HTML with an embedded JavaScript to call the function giving
  // it our message(in your app it doesn't have to be a string) as the first parameter.
  echo '<!DOCTYPE html><html><head></head><body><script type="text/javascript">',
       "try{window.top.$callback(\"$output\")}catch(e){}</script></body></html>";
} else {
  // Caller reads data with XMLHttpRequest so we can output it raw. Real apps would
  // usually pass and read a JSON object instead of plan text.
  header('Content-Type: text/plain; charset=utf-8');
  echo $output;
}

aspx页面:

<asp:Content ID="Content2"  ContentPlaceHolderID="MainContent" runat="server">
<div id="zone3">
  <p class="legend">Drop a file inside...</p>
</div>

       <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"> </script>
        <script type="text/javascript" src="Scripts/filedrop.js"></script>
            <script type="text/javascript">
                var zone = new FileDrop('zone3')

                zone.event('send', function (files) {
                    files.each(function (file) {
                        // Listen for errors:
                        file.event('error', function (e, xhr) {
                            alert(xhr.status + ', ' + xhr.statusText)
                        })

                        file.sendTo('Scripts/upload.php')
                    })
                })

      </script>
阿林丹·纳亚克(Arindam nayak)

如您所说the file is in fact at this location because if I go to the URL it downloads the PHP file.,这意味着PHP文件不会被执行,而是作为简单文件下载。要使其可执行,首先您必须将其放入Apache服务器并尝试使用该URL。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

ASP.NET和jQuery无法加载资源:服务器的响应状态为405(不允许使用方法)

来自分类Dev

HTTP删除,响应状态:405(不允许使用方法)

来自分类Dev

HTTP删除,响应状态:405(不允许使用方法)

来自分类Dev

状态码405(不允许使用方法)

来自分类Dev

(405)不允许使用方法。WCF Web服务

来自分类Dev

405不允许使用方法

来自分类Dev

选项405(不允许使用方法)

来自分类Dev

@PUT球衣错误405:不允许使用方法

来自分类Dev

CORS 405(不允许使用方法)

来自分类Dev

405(不允许使用方法),并被CORS策略阻止

来自分类Dev

CORS 405(不允许使用方法)

来自分类Dev

getRefreshInfo返回405(不允许使用方法)

来自分类Dev

405(不允许使用方法)DELETE

来自分类Dev

@PUT球衣错误405:不允许使用方法

来自分类Dev

Angular 2和Eclipse-无法加载资源:服务器响应状态为404

来自分类Dev

无法加载资源:服务器对mapbox api的响应状态为401

来自分类Dev

无法加载资源:服务器响应状态为404(未找到),角度js + ionic

来自分类Dev

收到错误消息“无法加载资源:服务器响应状态为404(未找到)”

来自分类Dev

无法加载COMPASS资源:服务器的响应状态为404(未找到)

来自分类Dev

无法加载资源:服务器响应状态为403(禁止)的MVC 5

来自分类Dev

无法加载资源; 服务器响应状态为 404 - bundles/jquery - MVC

来自分类Dev

Angular 2 - 无法加载资源:服务器响应状态为 404(未找到)

来自分类Dev

无法加载资源:服务器...响应状态为 404(未找到)

来自分类Dev

Shinyapps.io-无法加载资源:服务器响应状态为500(内部服务器错误)

来自分类Dev

Shinyapps.io-无法加载资源:服务器响应状态为500(内部服务器错误)

来自分类Dev

加载资源失败:服务器响应状态为500(使用信号功能...)

来自分类Dev

访问/刷新执行器不起作用时出现意外错误(类型=不允许使用方法,状态= 405)错误

来自分类Dev

加载资源失败:服务器响应状态为 500(内部服务器错误)

来自分类Dev

EJS:加载资源失败:服务器使用循环响应状态为 500(内部服务器错误)

Related 相关文章

  1. 1

    ASP.NET和jQuery无法加载资源:服务器的响应状态为405(不允许使用方法)

  2. 2

    HTTP删除,响应状态:405(不允许使用方法)

  3. 3

    HTTP删除,响应状态:405(不允许使用方法)

  4. 4

    状态码405(不允许使用方法)

  5. 5

    (405)不允许使用方法。WCF Web服务

  6. 6

    405不允许使用方法

  7. 7

    选项405(不允许使用方法)

  8. 8

    @PUT球衣错误405:不允许使用方法

  9. 9

    CORS 405(不允许使用方法)

  10. 10

    405(不允许使用方法),并被CORS策略阻止

  11. 11

    CORS 405(不允许使用方法)

  12. 12

    getRefreshInfo返回405(不允许使用方法)

  13. 13

    405(不允许使用方法)DELETE

  14. 14

    @PUT球衣错误405:不允许使用方法

  15. 15

    Angular 2和Eclipse-无法加载资源:服务器响应状态为404

  16. 16

    无法加载资源:服务器对mapbox api的响应状态为401

  17. 17

    无法加载资源:服务器响应状态为404(未找到),角度js + ionic

  18. 18

    收到错误消息“无法加载资源:服务器响应状态为404(未找到)”

  19. 19

    无法加载COMPASS资源:服务器的响应状态为404(未找到)

  20. 20

    无法加载资源:服务器响应状态为403(禁止)的MVC 5

  21. 21

    无法加载资源; 服务器响应状态为 404 - bundles/jquery - MVC

  22. 22

    Angular 2 - 无法加载资源:服务器响应状态为 404(未找到)

  23. 23

    无法加载资源:服务器...响应状态为 404(未找到)

  24. 24

    Shinyapps.io-无法加载资源:服务器响应状态为500(内部服务器错误)

  25. 25

    Shinyapps.io-无法加载资源:服务器响应状态为500(内部服务器错误)

  26. 26

    加载资源失败:服务器响应状态为500(使用信号功能...)

  27. 27

    访问/刷新执行器不起作用时出现意外错误(类型=不允许使用方法,状态= 405)错误

  28. 28

    加载资源失败:服务器响应状态为 500(内部服务器错误)

  29. 29

    EJS:加载资源失败:服务器使用循环响应状态为 500(内部服务器错误)

热门标签

归档