Topic: Html4 runtime problems

Hi,
I'm new to plupload so I may be doing something wrong, but I can't get the html4 runtime to work. Under Internet Explorer, I select a file to upload and start the uploader. However, then I see a dialog "Do you want to open or save this file" with upload.php as the selected file. So it appears to be trying to download the results of the post to upload.php rather than treat it as an AJAX response.

Also, under FireFox HTML4 appears to work but I don't get an uploaded file.

Any thoughts what I am doing wrong, or is this a bug?

Re: Html4 runtime problems

Thanks. I'm not sure what you mean by "integration with an application", but actually I think it is the second one. If I put some debug code in my  upload.php file, I can see the content type is multipart, but the $_FILES array is empty when using Internet Explorer 8 & html4.

Has anybody actually got this setup working?

3 (edited by johnvb 2010-05-21 20:29:17)

Re: Html4 runtime problems

Still no luck on this. I've just downloaded the latest version, 1.2.2.1, which claims to have some fixes in this area, but it makes no difference. In fact now even the example page http://www.plupload.com/example_all_runtimes.php does not work for HTML4 on IE8. When you select a file it is fine, but then when you press upload IE opens a download box as it is trying to open the JSON response from the upload.php script rather than use it as a JSON response properly.

On my own code, I get the same problem, but only after implementing another bugfix I found. In the HTML4 runtime, on line 213, it says:

// Append to form
container.appendChild(inputContainer);

But this means the inputContainer is appended to the container, not the form that is going to be submitted. So it gets stuck in the wrong place in the DOM and is not included in the POST. So, I found that if I replace container with form it works, or at least now it sends the correct POST data:

// Append to form
form.appendChild(inputContainer);

Any help would be much appreciated, as we are going live on a project on Monday.

Re: Html4 runtime problems

The download dialog on IE 8 is produced by the text/plain content type. We will try to make it possible to have the text/html content type. Even though it's wrong it would then work on IE on the HTML4 runtime.

Re: Html4 runtime problems

Oh, just realized that it's fixed. Just set the content-type in upload.php to text/html and you are done.

Re: Html4 runtime problems

Thanks Spocke for the very timely reply. It works a treat, but I am still a bit confused why I need to change the code in the HTML4 runtime to add the inputContainer to the form rather than the container. Is this a bug?

Another point I have picked up is that on IE7 I could not get the file open dialog to appear with the HTML 4 runtime. With a bit of css hacking I got a red border to appear round the shim, and realised it was off to the left of where it should be. The reason is my template sets the body css to margin: auto with a fixed width, positioning the body in the middle of the browser. In IE8 and Firefox, the call to plupload.getPos correctly takes this into account, returning the x as 485 pixels. But in IE7 it seems to be unaware that the body is centred, and returns 45 pixels. I found that this difference is reflected by document.body.offsetLeft so I have changed the html4 runtime's shim positioning code in my copy to:

plupload.extend(document.getElementById(uploader.id + '_iframe_container').style, {
    top : browsePos.y + 'px',
    left : (browsePos.x+document.body.offsetLeft) + 'px',
    width : browseSize.w + 'px',
    height : browseSize.h + 'px'
});

Does this make sense?

Re: Html4 runtime problems

The container setting should work. Then the shim will be positioned relative to the containers offset and there for not be affected by the bodys alignment etc.

Re: Html4 runtime problems

I must be missing something here, I can't see how it will work if the inputContainer is appended to the container. Assuming you don't override the default behaviour through the settings, line 60 sets container = document.body. The body contains the form, obviously, so if you add the inputContainer to the container (=document.body) it is effectively an orphaned input element. When you submit the form, the image file is not included in the post data. The inputContainer must be added to the form, or an element inside the form, or you can't upload the image in the form submission.
Any thoughts? Thanks for responding to my questions though Spocke, it may sound like I am moaning, but I appreciate being able to bounce these things off the developer whether they turn out to be bugs or issues in my code.

Re: Html4 runtime problems

The container works just fine. The QueueWidget uses it so if it didn't that one wouldn't work. So I think this is some form of implementation issue.

It puts the input element inside a div element that is positioned absolute within the relative container element if it's specified.

I didn't write the whole plugin it was a third party contribution, but it does work as expected. Made some changes here and there to improve on some of the edge cases.

Re: Html4 runtime problems

Got it. We had written our own jQuery plugin instead of using QueueWidget, so that it would fit in well with the way the rest of our code library worked. But in our case, we did not specify the container setting in the call to plupload, as it is optional. If you take a look at the HTML4 runtime you will see that if container is not specified, document.body is used for the container, which does not work. You need to specify the container as an element which is within the form.
I'd suggest 2 small changes, first to correct the documentation for container:

Element ID to add object elements to, this defaults to the document body element.

And second to force some sort of error rather than using document.body if the container is not supplied.

Thanks again for your help.
John

11 (edited by qualle 2011-02-03 15:02:37)

Re: Html4 runtime problems

Hi there,

same problem here with plupload v1.4.1. I'am using the API to access the script. Works fine in html5 mode but the IE (html4) tries to open/download the upload.php with the response

{"jsonrpc" : "2.0", "result" : null, "id" : "id"}

My Script looks like this:

var uploader = new plupload.Uploader({            
        runtimes : 'html5,html4',
        url : 'upload.php',
        container : 'pluploader',
        browse_button : 'pluploader_addfiles',
        drop_element: 'pluploader_dropzone',        
        max_file_size : '500mb',
        chunk_size : '2mb',
        unique_names : false,
        
        // more code here
});

Markup:

<div id="pluploader">
                <div class="pluploader_header">
                    <div class="pluploader_fileoptions">&nbsp;</div>
                    <div class="pluploader_filename">Filename</div>
                    <div class="pluploader_filesize">Size</div>
                    <div class="pluploader_filestatus">Status</div>
                </div>
                <div class="pluploader_content">
                    <div id="pluploader_dropzone" class="pluploader_dropzone">&nbsp;</div><div id="pluploader_filelist" class="pluploader_filelist"></div>
                </div>
                <div class="pluploader_footer">
                    <div id="pluploader_addfiles" class="pluploader_button pluploader_add">Add files</div>
                    <div id="pluploader_uploadfiles" class="pluploader_button pluploader_start">Start upload</div>
                    <div id="pluploader_totalsize" class="pluploader_totalsize">&nbsp;</div>
                    <div id="pluploader_totalstatus" class="pluploader_totalstatus">&nbsp;</div>
                    <br class="clear" />
                </div>
            </div>

As you can see I already have the container defined... any suggestions?

Regards,
qualle

Re: Html4 runtime problems

Workaround is to outcomment the following line in upload.php:

header('Content-type: text/plain; charset=utf-8');

Re: Html4 runtime problems

Hello,
I am a new member to plupload and was experiencing the same issues with getting html4 runtime to work...  but thanks to the forum support and feedback I was able to do some troubleshooting and get the problem resolved!

Thanks for the great support.

Re: Html4 runtime problems

@rthie: Was was your solution?