根据Filestack Docs,我想总结我在Filestack中上传的所有文件页数,因此我使用 output = docinfo:true 选项,以JSON格式显示文件信息,以及以这种方式显示AJAX:
var client = filestack.init('myAPI');
client.pick({
/* my options */
}).then(function(Blobs){
var result = JSON.parse(JSON.stringify(Blobs));
for(var i=0; i<result.filesUploaded.length; i++){
var dataFile = "https://cdn.filestackcontent.com/output=docinfo:true/"+result.filesUploaded[i].handle;
$.post("numpage.php",{
dF: dataFile
}).success(function(response){
var np = response++;
console.log("Total number of pages: "+np);
});
}
});
numpage.php
<?php
$url = $_POST['dF'];
$str = file_get_contents($url);
$json = json_decode($str);
$obj2 = $json->{'numpages'};
echo $obj2;
?>
但是在控制台中只显示了1页,当我继续上传文件时,它仍然在控制台中显示1页。我该如何解决?
我想要一些帮助。谢谢!