开发者

How to Debug Uploadify?

开发者 https://www.devze.com 2023-03-18 00:40 出处:网络
I don\'t know how to debug Uploadify. All seems to be working, but there are no actual file uploaded. From browser... Upladify event prints \"Done!\". Before I used Uploadify, PHP code worked... so I

I don't know how to debug Uploadify. All seems to be working, but there are no actual file uploaded. From browser... Upladify event prints "Done!". Before I used Uploadify, PHP code worked... so I don't know where is the problem.

<input id="file_upload" name="file_upload" type="file" rel="<?php echo $group_id; ?>" />

(without <form>)

In Javascript...

$('#file_upload').uploadify({
    'uploader'       : '/media/js/uploadify/uploadify.swf',
    'script'         : '/bio/community/group_picture/' + $('#file_upload').attr('rel'),
    'cancelImg'      : '/media/img/bio/_blog_delete.png',
    'buttonImg'      : '/media/img/bio/browse_files.png',
    'wmode'          : 'transparent',
    'auto'           : true,
    'width'          : 92,
    'sizeLimit'      : 31457280,       
    'height'         : 26,
    'scriptData'     : {'session' : session_id},
    'onAllComplete'  : function() {  location.reload(); }
});

In PHP:

Controller:

public function action_group_picture($group_id) {

    $model_group = Model::factory('Bio_Community_Group');

    if (!empty($_FILES)) {

        $model_group->add_picture($_FILES['file_upload'], $group_id);

        $this->request->redirect('bio/community/edit_group/' . $group_id);

    }

    exit;

}

Model:

public function add_pi开发者_如何学Gocture($image, $group_id) {

    $filename = $group_id . '.jpg';
    $location = 'uploads/bio/community/groups/' . $filename;

    $image = Image::factory($image['tmp_name']);

    if ($image->width !== 60 || $image->height !== 60) {

        $image->crop(60, 60);

    }

    $image->save($location);

}

I'm using Kohana, by the way. Any ideas why it doesn't work or how to debug?


Try using debug:true.

It shows a box with the script's log:

$(function() {
    $("#file_upload").uploadify({
        'debug'    : true,
        'swf'      : '/uploadify/uploadify.swf',
        'uploader' : '/uploadify/uploadify.php' 
    });
});


  1. Use Firebug (FireFox plugin) to get information about request info (headers, HTTP response etc).
  2. Add logging into controller (like a request savepoints).
  3. Check httpd logs.


I write all the js events out to the console. There are a lot of them: onSelect, onOpen, onProgress, onComplete, etc. This can give you a little more idea of what's happening when uploadify is working.

For example:

onComplete : function ( event, ID ...
    console.log( event );   
    console.log( ID );
    ....

etc., etc.

See here: http://www.uploadify.com/documentation/

In general, though, seeing inside it is a pain. My charles doesn't catch the server traffic for some reason.....

EDIT: also, another thing I tend to forget when I'm deep in the JS and things are not returning correctly: Is my server-side call error free? Uploadify doens't return the text of any http status codes you send in your response, so even if you are giving back a 503 or whatever, you don't get your own error text. I try to make a dummy html-only file submit form so I can make sure that my server side code is correct.

(side note: Uploadify also doesn't, for some reason, recognize http status code 400 as an error, even tho it's in the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1 )

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号