balex balex - 1 year ago 93
Ajax Question

Ajax Post with Filename as Parameter

I know how to do an Ajax Post to a PHP File wich writes/creates a File on the Server. But is it possible to send a Parameter wich tells the PHP how the file wich should be created is named?

Thank you in advance!

Answer Source

In your Javascript code add data to pass to php script:

    method: 'POST',
    url: '/your_php_script.php',
    data: {
      filename: 'some_name'

In your PHP script:

$filename = $_POST['filename'];