I want the user to insert in my page a PDF or image file. Then i want to upload that file via SFTP with PHPSECLIB. I want to pass the file via ajax with some more data.
var file = this.files[0];
alert('You have chosen the file ' + file.name);
var data = new FormData();
data.append('file', file);
var url_string = window.location.href;
var url = new URL(url_string);
var id = url.searchParams.get("id");
var url="Invoice/uploadInvoice"
console.log(data);
console.log(file);
$.ajax({
url: "/SPI/Invoice/uploadInvoice", // point to server-side PHP script
dataType: 'text', // what to expect back from the PHP script, if anything
cache: false,
contentType: false,
processData: false,
data: {file : data , id:id},
type: 'POST',
success: function(php_script_response){
alert(php_script_response); // display response from the PHP script, if any
}
});
});
I expect someting in POST in function uploadInvoice and its output is NULL.