2

Need to save some big data to file on server

"/php/test.php":

<?php if(!empty($_POST['data'])){
    $data = $_POST['data'];
    $fname = mktime() . ".txt";
    $file = fopen("upload/" .$fname, 'w');
    fwrite($file, $data);
    fclose($file);
    }
?>

jquery:

var data = 'foo bar';
$.ajax({
    url: 'php/test.php',
    type: 'POST',
    data: { data: data },
    success: function(result) {
        alert('the data was successfully sent to the server');
    }
});

result:

405 (HTTP method POST is not supported by this URL)

what's the problem?

CrazyDaddy
  • 29
  • 2
  • 3
    The (unspecified) server is configured not to allow POST requests to that URL. – Quentin Apr 25 '16 at 09:10
  • Aside from the error you have, here's a question which covers how to achieve what you need: http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously – Rory McCrossan Apr 25 '16 at 09:16
  • 1
    Your server does not support the "POST" method. For details please follow the link: http://www.asp.net/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications http://www.checkupdown.com/status/E405.html – Dipanwita Kundu Apr 25 '16 at 09:28
  • Thanks for answers, will search another way – CrazyDaddy Apr 25 '16 at 09:34

0 Answers0