views:

507

answers:

2

I'm trying to upload files using swfuploder and it works fine in IE.But its getting "UploadError 403" in Firefox. I'm using apache-tomcat-6.0.16 and couldnt access the .htaccess file as well.

This is my code to use for swfupload.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>SWFUpload Demos - Simple Demo</title>
        <link href="../css/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../js/swfupload/demos/swfupload/swfupload.js"></script>
        <script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/swfupload.queue.js"></script>
        <script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/fileprogress.js"></script>
        <script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/handlers.js"></script>
        <script type="text/javascript">
            var swfu;
            window.onload = function() {
                var settings = {
                    flash_url : "../js/swfupload/demos/swfupload/swfupload.swf",
                    upload_url: "upload_pages/uploader.jsp",
                    post_params: {"PHPSESSID" : ""},
                    file_size_limit : "100 MB",
                    file_types : "*.*",
                    file_types_description : "All Files",
                    file_upload_limit : 100,
                    file_queue_limit : 0,
                    custom_settings : {
                        progressTarget : "fsUploadProgress",
                        cancelButtonId : "btnCancel"
                    },
                    debug: true,
                    prevent_swf_caching: true,

                    // Button settings
                    button_image_url: "../js/swfupload/demos/simpledemo/images/TestImageNoText_65x29.png",
                    button_width: "65",
                    button_height: "29",
                    button_placeholder_id: "spanButtonPlaceHolder",
                    button_text: '<span class="theFont">Upload</span>',
                    button_text_style: ".theFont { font-size: 16; }",
                    button_text_left_padding: 12,
                    button_text_top_padding: 3,

                    // The event handler functions are defined in handlers.js
                    file_queued_handler : fileQueued,
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_start_handler : uploadStart,
                    upload_progress_handler : uploadProgress,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadSuccess,
                    upload_complete_handler : uploadComplete,
                    queue_complete_handler : queueComplete
                };

                swfu = new SWFUpload(settings);
            };
        </script>
    </head>
    <body>
        <div id="content">
            <h2>File Upload</h2>
            <form id="form1" method="post" enctype="multipart/form-data">
                <div class="fieldset flash" id="fsUploadProgress">
                    <span class="legend">Upload Queue</span>
                </div>
                <div id="divStatus">0 Files Uploaded</div>
                <div>
                    <span id="spanButtonPlaceHolder"></span>
                    <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
                </div>
            </form>
        </div>
    </body>
</html>

I have tried with both absolute and relative url for "upload_url" but the same error "uploadError 403" appears.But it works for IE.

A: 

HTTP status code 403 means Forbidden. This is an authentication error. The request requires an authenticated user (logged-in user), but either the user isn't there in the session, or the associated session cannot be found.

I have never used SWFUpload, but it look like that it didn't pass the jsessionid cookie along with the request to the server side, so that the server side cannot identify the client. Googling "swfupload jsessionid" also learns that you're not the only one who encountered this particular problem. To fix this, you need to append the jsessionid to the URL in the settings:

upload_url: "upload_pages/uploader.jsp;jsessionid=${pageContext.session.id}",

That said, the following line

post_params: {"PHPSESSID" : ""},

looks suspicious as well. What is an empty PHP session ID doing there in a JSP/Servlet environment? Aren't you overlooking/forgotting this while copypasting someone else's code?

BalusC
I'm trying the simple upload demo example given in http://demo.swfupload.org/v220/index.htm.. Well post_params: {"PHPSESSID" : ""}, doing nothing here. This code works for IE.. I have append the jsessionid to the URL.But still the same error 403 occurs.
devuser
A: 

I'm trying the simple upload demo example given in http://demo.swfupload.org/v220/index.htm.. Well post_params: {"PHPSESSID" : ""}, doing nothing here. This code works for IE.. I have append the jsessionid to the URL.But still the same error 403 occurs.

devuser