requests.post(url, data={'interests':'football','interests':'basketball'})
Run Code Online (Sandbox Code Playgroud)
我尝试过这个,但它没有用.我将如何张贴football,并basketball在interests现场?
如何使用vue.js发送文件?
以下代码对我不起作用:
<span title="Upload" class="badge badge-info">
<input type="file" id="file" name="file" @change="uploadData" class="archive" > <i id="iarchive" class="fa fa-upload"></i>
</span>
Run Code Online (Sandbox Code Playgroud)
当我做console.log(this.request.file)我得到FILE [object File]。
这是.js:
uploadData: function(e) {
var files = e.target.files[0];
this.request.action = 'upload';
this.request.file = files;
console.log("FILE "+this.request.file);
this.$http.post('data/getData.php', {
data: this.request,
headers: {
'Content-Type': 'multipart/form-data'
}
}
).then(function(response) {
console.log("RESPONSE: "+response.body);
}, function(response) {
alert("error");
});
return false;
}
Run Code Online (Sandbox Code Playgroud)
但是在PHP中,我无法获取文件,响应为:{} No properties。
PHP代码:
$request = json_decode(file_get_contents('php://input'));
$req = $request->data;
echo json_encode($req->file)
Run Code Online (Sandbox Code Playgroud) 我需要运行另一个必须能够运行我的应用程序的安装程序。如何启动其他安装程序,或在Wix安装程序内部提供选项?
如果在同一个函数中重新声明和定义了相同的全局变量,为什么这个全局变量在函数中未定义?
var a = 1;
function testscope(){
console.log(a, 'inside func');
//var a=2;
};
testscope();
console.log(a, 'outside func');
output:
1 "inside func"
1 "outside func"
Run Code Online (Sandbox Code Playgroud)
考虑相同的代码,其中 var a = 2; 内部功能块未注释
var a = 1;
function testscope(){
console.log(a, 'inside func');
var a=2;
};
testscope();
console.log(a, 'outside func');
Output
undefined "inside func"
1 "outside func"
Run Code Online (Sandbox Code Playgroud)