我希望用户在我的页面的PDF或图像文件插入。然后我想通过SFTP上传该文件与PHPSECLIB。我想通过AJAX多用一些数据来传递文件。
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
}
});
});
我想到的东西在岗功能上传发票和其输出为NULL。
我在这里所做的是让由elementID文件并获得第一个也是唯一的文件在从输入位置0。
var url_string = window.location.href;
var url = new URL(url_string);
var id = url.searchParams.get("id");
var url="Invoice/uploadInvoice"
var form_data = new FormData();
form_data.append("id", id);
form_data.append("nrinvoice" , document.getElementById('nrinvoice').value);
form_data.append("file", document.getElementById('input-excel').files[0]);
$.ajax({
url:"<?php echo base_url('/Invoice/uploadInvoice') ?>/",
method:"POST",
data: form_data,
contentType: false,
cache: false,
processData: false,
....