No vaild message received from loaded iframe for iframe

假如想象 提交于 2019-12-11 21:26:06

问题


Some help with the following please.

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

Thank you for response, however still did not work. Get upload fail. Do I pass the response back as text/html or text/plain

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>";
}

?>

This is the response i get back from ie9/8

[FineUploader 3.9.0-3] Received 1 files or inputs.

[FineUploader 3.9.0-3] Sending upload request for 0

[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] Received the following window message: '{"success":true,"uuid":"9da17ad5-ad6a-40cd-81b5-226e837db45b"}'

[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 loaded


回答1:


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>";

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:

  • 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 to false, so you don't need to explicitly set this.
  • The cors.sendCredentials option defaults to false, so you don't need to explicitly set this.


来源:https://stackoverflow.com/questions/19555206/no-vaild-message-received-from-loaded-iframe-for-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!