没有从iframe的加载iframe收到任何虚假消息 [英] No vaild message received from loaded iframe for iframe
问题描述
请给以下一些帮助。
嗨雷,我现在正在为IE7 / 8正确回复。然而,它立即回来,firefox正在花时间上传一个百分比栏来表明这一点。我担心因为某人可能上传然后看到它已完成然后保存并且视频将不在那里。有关为什么IE7 / 8会立即显示响应的任何建议。希望有意义
Hi Ray, I am now getting response correctly back for IE7/8. However it comes back immediately, where firefox is taking its time to upload with a percentage bar to indicate this. I am worried cause someone may upload and then see it is done then save and the video won't be there. Any suggestions as to why IE7/8 would show response immediately. Hope that makes sense
感谢您的回复,但仍然无效。上传失败。我是否以文本/ html或text / plain
Thank you for response, however still did not work. Get upload fail. Do I pass the response back as text/html or text/plain
的形式将响应传回给oncomplete函数是否是正确的响应日志?
also on the oncomplete function is that the correct response log?
uploader = $jq('#fine-uploader').fineUploader({
debug: true,
request: {
//endpoint: 'http://video-api.shannons.com.au/api/upload/upload.php',
endpoint: 'http://crowleyroofing.radiusmedia.com.au/uploader-test.php',
params: {
ClientToken: token,
ApplicationResponse: 'FineUploader'
},
inputName: 'FileUpload'
},
cors: {
expected: true
},
multiple: false,
validation: {
allowedExtensions : ['mp4','mov','ogm','ogv','ogx','webm','flv','avi','m4v','mkv','wmv'],
sizeLimit : 52428800
},
showMessage: function(message) {
$('.video-error').append('<div class="alert alert-error">' + message + '</div>');
}
})
.on('submit', function(event, id) {
$('.qq-upload-button').hide();
$('.qq-upload-list').show();
})
.on('complete', function(event, id, name, response) {
console.log(response);
//$jq('.qq-upload-status-text').html(response);
/*$jq('#event-post-form').prepend('<input id="mediatoken" type="hidden" name="mediatoken" value="' + response.Data.MediaId + '">');
var size = $('.qq-upload-size').text();
var html = '' + name + ' ' + size + ' <span class="icon"><em class="club-tick"></em></span>';
$jq('.qq-upload-status-text').html(html);*/
});
PHP here
<?php
function gen_uuid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand( 0, 0x0fff ) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand( 0, 0x3fff ) | 0x8000,
// 48 bits for "node"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
);
}
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, cache-control');
header("Content-Type: text/html");
$data = array("success" => true, "uuid" => gen_uuid());
$json = json_encode($data);
echo "$json <script src=\"http://crowleyroofing.radiusmedia.com.au/iframe.xss.response-3.9.0-3.js\"></script>";
}
?>
这是我从ie9 / 8获得的回复
This is the response i get back from ie9/8
[FineUploader 3.9.0-3]收到1个文件或输入。
[FineUploader 3.9.0-3] Received 1 files or inputs.
[FineUploader 3.9.0-3]发送上传请求为0
[FineUploader 3.9.0-3] Sending upload request for 0
[FineUploader 3.9.0-3]接收到CORS上传请求的iframe加载事件(iframe名称0_89b9b578-b08e-4221-be2b-a1bac04792c8)
[FineUploader 3.9.0-3] Received iframe load event for CORS upload request (iframe name 0_89b9b578-b08e-4221-be2b-a1bac04792c8)
[FineUploader 3.9.0-3]收到以下窗口消息:'{success:true, uuid:9da17ad5-ad6a-40cd-81b5-226e837db45b}'
[FineUploader 3.9.0-3] Received the following window message: '{"success":true,"uuid":"9da17ad5-ad6a-40cd-81b5-226e837db45b"}'
[FineUploader 3.9.0-3]从iframe名称的已加载iframe收不到有效消息0_89b9b578-b08e-4221-be2b-a1bac04792c8
[FineUploader 3.9.0-3] No valid message received from loaded iframe for iframe name 0_89b9b578-b08e-4221-be2b-a1bac04792c8
[FineUploader 3.9.0-3] iframe已加载
[FineUploader 3.9.0-3] iframe loaded
推荐答案
对于IE9或更早版本发起的跨域上传,您没有返回正确的响应。 如文档所述,您必须返回包含指向 iframe.xss.response.js
文件的脚本标记的text / html响应,以及包含成功的有效JSON字符串
属性值 true
和 uuid
属性,其值等于UUID相关文件的。
Your aren't returning a proper response for cross-origin uploads initiated by IE9 or older. As the documentation states, you must return a text/html response that contains a script tag pointing to the iframe.xss.response.js
file, and a valid JSON string that contains a success
property with a value of true
AND a uuid
property with the value equal to the UUID of the associated file.
您的回复代码应如下所示:
Your response code should look something like this:
$data = array("success" => true, "uuid" => "9da17ad5-ad6a-40cd-81b5-226e837db45b");
$json = json_encode($data);
echo "$json <script src=\"http://crowleyroofing.radiusmedia.com.au/iframe.xss.response-3.9.0-3.js\"></script>";
您需要更换 uuid $ c $的值c>属性值为
qquuid
参数Fine Uploader随上传请求一起发送。
Your will need to replace the value of the uuid
property with the value of the qquuid
parameter Fine Uploader sends with the upload request.
此外,请注意以下与您的代码无关的问题:
Also, note the following, unrelated issues with your code:
- 无需启用
cors.allowXdr
选项。只有在跨源环境中启用了删除文件功能时才会使用此选项。 -
debug
选项默认为false
,因此您无需明确设置此项。 -
cors.sendCredentials
选项默认为false
,因此您无需显式设置。
- There is no need to enable the
cors.allowXdr
option. This is only used if you have the delete file feature enabled in cross origin environments. - The
debug
option defaults tofalse
, so you don't need to explicitly set this. - The
cors.sendCredentials
option defaults tofalse
, so you don't need to explicitly set this.
这篇关于没有从iframe的加载iframe收到任何虚假消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!