Problem with IE7 and qfileasset

Login or register to post comments
24 replies [Last post]
Offline
Joined: 04/06/2009

Hi,

I have noticed this issue today with IE7. I normally test in Fifrefox so I must have missed this.

Problem is the first time you try and upload an Image, qcubed seems to simply refresh and prompt for an image again. After this initial 'reprompt' for a file, subsequent uploads work fine until a serverControlAction takes place.

The behaviour is similar to that reported in bug 88 where an image had to be uploaded twice after being deleted.

This issue seems to be IE related (works fine in Firefox). I've spent all day searching for a solution but am stuck. What's worse is I don't even know where to start trouble shooting the issue from.

Can anybody confirm the issue and help me out. I have tried replicating the issue on the examples site here, but it seems to work fine. I have also looked at the code creating the asset and it is the same as the example code. I have no idea where to start with this one.

Offline
Joined: 04/06/2009

Anybody?

alex94040's picture
Offline
Joined: 11/06/2008

Hmmm, this is rather strange. Like you said, the fix for bug 88 should have fixed this - and I personally verified that it's fixed on the examples site (as it is on my own servers).

What version of QCubed are you using?

It seems that since you aren't able to reproduce the issue on the qcubed examples site, there's something going on with your server setup (as IE7 works just fine on the examples site).

Offline
Joined: 04/06/2009

I'm using beta 2 ... for some reason IE7 is returning null when a file is submitted the first time, after that it works :S. Firefox returns a file as expected and so does not throw the error.

The only other thing i can think of is that I am running the qfileasset out of a qpanel, the example site runs it out of a qform. Would this have any impact on the result?

I have also installed the examples on my own server using the same instance of qcubed, and they work ... like i said the only difference i can see between my application and the example is the use of qpanels instead of qforms.

Any ideas anyone?

Edit: I have found that for some reason, when IE posts the upload the $_FILES array is empty. Again, this only seems to happen in a QPanel, the example in a QForm populates as expected.

k9
Offline
Joined: 11/19/2008

there's your problem. Don't use beta 2 but upgrade to the latest QCubed

alex94040's picture
Offline
Joined: 11/06/2008

I think what k9 is trying to say is that in the RC2 changelog, there's a bug #99 that we fixed that explicitly addressed this issue. Please upgrade to QCubed RC2.

If we misunderstood you and you're already running QCubed RC2, I'd love to learn more about your setup. Can you paste in a relevant code snippet? Also, which browser(s) are you able to repro this on?

Offline
Joined: 04/06/2009

Hi,

Thanks for your interest guys.

My mistake, I am using RC2. I am experiencing the issue on multiple setups. I am trouble shooting the issue on a local xampp installation. Near default settings with several vhosts setup and changes to max file size and execution time.

As I said the example (QForm) works fine on the local setup ... but for some reason a QPanel+QFileAsset does not.

The issue appears to be IE specific, firefox works fine. I have examined the dom before and after a file is selected and it seems to be updating the <input> tag properly. However on POST the $_FILES superglobal is empty in IE but not in FF (works fine), prompting for a file once again. Again selecting a file updates the the DOM properly and this time IE does POST the correct $_FILES value successfully uploading the file. Any further deletes and uploads work fine past this point and even after saving and creating a new entity to upload.

The problem reappears if the page is refreshed or reloaded. Again the first upload fails with an empty $_FILES variable and works fine after that initial failure.

It's almost as if IE is not seeing the <input > tag the first time the file is uploaded. I was thinking perhaps programatically forcing a failed upload once when the QFileAssetDialog is opened might fool IE (and the user) into behaving as desired, but this is a really hacky way of 'hiding' the problem and I still don't really know how I would do that.

This is the code creating the panel. It's originally generated by the latest qcodo (0.3.43) with some slight modifications to the panel to allow for the qfileasset and some custom save code to resize the uploaded image (the failure occurs before the save method is called).

class GalleryEditPanel extends QPanel {
       
        // Local instance of the GalleryMetaControl
        protected $mctGallery;

        // Controls for Gallery's Data Fields
        public $lblId;
        public $txtTitle;
        public $txtImage;
        public $txtCaption;
        public $lstCategoryObject;
        public $flaImage;

        // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References

        // Other Controls
        public $btnSave;
        public $btnDelete;
        public $btnCancel;

        // Callback
        protected $strClosePanelMethod;

        public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
           
            // Call the Parent
            try {
                parent::__construct($objParentObject, $strControlId);
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }

            // Setup Callback and Template
            $this->strTemplate = 'GalleryEditPanel.tpl.php';
            $this->strClosePanelMethod = $strClosePanelMethod;

            // Construct the GalleryMetaControl
            // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
            $this->mctGallery = GalleryMetaControl::Create($this, $intId);

            // Call MetaControl's methods to create qcontrols based on Gallery's data fields
            $this->lblId = $this->mctGallery->lblId_Create();
            $this->txtTitle = $this->mctGallery->txtTitle_Create();
            $this->flaImage = $this->mctGallery->flaImage_Create();
            $this->txtCaption = $this->mctGallery->txtCaption_Create();
            $this->lstCategoryObject = $this->mctGallery->lstCategoryObject_Create();

            // Create Buttons and Actions on this Form
            $this->btnSave = new QButton($this);
            $this->btnSave->Text = QApplication::Translate('Save');
            $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
            $this->btnSave->CausesValidation = $this;

            $this->btnCancel = new QButton($this);
            $this->btnCancel->Text = QApplication::Translate('Cancel');
            $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));

            $this->btnDelete = new QButton($this);
            $this->btnDelete->Text = QApplication::Translate('Delete');
            $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Gallery') . '?'));
            $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
            $this->btnDelete->Visible = $this->mctGallery->EditMode;
        }

        // Control AjaxAction Event Handlers
        public function btnSave_Click($strFormId, $strControlId, $strParameter) {
            // Delegate "Save" processing to the GalleryMetaControl
            $this->mctGallery->SaveGallery();
            $this->CloseSelf(true);
        }

        public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
            // Delegate "Delete" processing to the GalleryMetaControl
            $this->mctGallery->DeleteGallery();
            $this->CloseSelf(true);
        }

        public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
            $this->CloseSelf(false);
        }

        // Close Myself and Call ClosePanelMethod Callback
        protected function CloseSelf($blnChangesMade) {
            $strMethod = $this->strClosePanelMethod;
            $this->objForm->$strMethod($blnChangesMade);
        }
    }

This is the function creating the QFileAsset:

class GalleryMetaControl extends GalleryMetaControlGen {

    protected $flaImage;
       
    public function flaImage_Create($strControlId = null) {
            $this->flaImage = new QFileAsset($this->objParentObject, $strControlId);
            $this->flaImage->Name = QApplication::Translate('Image');
            $this->flaImage->Required = true;
            $this->flaImage->ClickToView = true;
            $this->flaImage->TemporaryUploadPath = __DOCROOT__.'/images/upload/temp';
            if ($this->objGallery->Image)
                $this->flaImage->File = __DOCROOT__.'/images/upload/thumbs/'.$this->objGallery->Image;
            return $this->flaImage;
        }
...

 

alex94040's picture
Offline
Joined: 11/06/2008

crembz,

Just to be sure: the example on the examples.qcu.be site works for you in that same IE7 browser? But that SAME exact example, when run on your local machine, does NOT work?

Thanks!

Offline
Joined: 03/31/2008

Yeah, this sounds a lot like bug #88, and discussed here: (or #99, discussed on that ticket page)

http://www.qcodo.com/forums/topic.php/2756/1

What was happening was that there ended up being two filename inputs, and IE was using the 2nd (blank) one as it's post. The patch there should definately have corrected the issue. Can you ensure your assets/js/core/control_dialog.js file has the code in green shown here:

http://trac.qcu.be/projects/qcubed/attachment/ticket/88/control_dialog.j...

Offline
Joined: 04/06/2009

Hi,

alex the example works in IE7 on both the examples.qcu.be and locally. The example is in a qform though, I believe the issue is in relation to the use of qfileasset in a qpanel.

vexed i have checked the control_dialog.js file and it seems to have patch 88 and 99 applied to it already:

var objControl; if (!(objControl = qcodo.getControl(mixControl))) return;
var objWrapper = objControl.wrapper;

objForm = document.getElementById(document.getElementById("Qform__FormId").value);
for (var x = 0; objForm.childNodes[x]; x++) {
if (objForm.childNodes[x].id == objWrapper.id && objForm.childNodes[x] != objWrapper) {
objForm.removeChild(objForm.childNodes[x]);
break;
}
}

var objPreviousElement = document.getElementById(objWrapper.id);
if (!objPreviousElement)
objForm.appendChild(objWrapper);

// Setup the DialogBoxBackground (DbBg) if applicable
objWrapper.dbBg = document.getElementById(objWrapper.id + "dbbg");
var objDbBg = objWrapper.dbBg;

Still banging my head with this one ... may have to revert to using a qform instead.

Offline
Joined: 03/31/2008

I've created a ticket for this at:
http://trac.qcu.be/projects/qcubed/ticket/221 (don't hesitate to create your own in the future)

If you've got any additional information or reproduce code, please post it there. :)

Offline
Joined: 04/06/2009

thanks for that, i didn't want to create a ticket because i wasn't sure whether this is a bug or my own inexperience with the system.

Have you managed to verify the issue for yourself?

Offline
Joined: 03/31/2008

No, but we do want to try, and if it does turn out to be just a problem with your code, then we can close the ticket. Either way, we want to ensure the core system is behaving correctly.

Offline
Joined: 07/10/2008

What operating system do you have?

Offline
Joined: 04/06/2009

I'm using Windows XP Pro with Xampp as my dev environment, but the issue also presents itself on a redhat linux box as well

The problem occurs both when creating a new 'GalleryObject' and when editing an existing one (remove then add a new image)

I dunno if I'm on the right track but the fact that this is an IE specific issue only when using qpanels leads me to believe that this is a javascript issue as opposed to a php or code issue. Any ideas anyone.

Offline
Joined: 04/06/2009

Still no progress on this one, been trying for a couple of weeks, out of ideas ... is anybody able to confirm this. I'm going to have to switch a few site over to qforms it's painful and I much prefer the panels

Offline
Joined: 04/06/2009

anybody had time to have a look into this one? .... any help would be appreciated. My boss is hassling me to find a fix and I just can't seem to get it working

enzo's picture
Offline
Joined: 03/31/2008

Hello pal

Do you have any url to check your code and a live example?

Regards

enzo
http://www.anexusit.com/blog/1

Offline
Joined: 04/06/2009

hi enzo,

sorry i haven't replied, been under the pump a little.

I'll set one up tomorrow for you tomorrow.

Thanks pal

Offline
Joined: 04/06/2009

I've made a little progress with this one. I also noticed it has been marked as invalid in the tracker ... does this mean nobody has experienced the issue?

Anyways it seems that the following code does work for me:

image_edit.php:

<?php
   
// Load the QCubed Development Framework
   
require('../includes/prepend.inc.php');

   
/**
     * This is a quick-and-dirty draft QForm object to do Create, Edit, and Delete functionality
     * of the Image class.  It uses the code-generated
     * ImageMetaControl class, which has meta-methods to help with
     * easily creating/defining controls to modify the fields of a Image columns.
     *
     * Any display customizations and presentation-tier logic can be implemented
     * here by overriding existing or implementing new methods, properties and variables.
     *
     * NOTE: This file is overwritten on any code regenerations.  If you want to make
     * permanent changes, it is STRONGLY RECOMMENDED to move both image_edit.php AND
     * image_edit.tpl.php out of this Form Drafts directory.
     *
     * @package My Application
     * @subpackage Drafts
     */
   
class SampleForm extends QForm {
   
    protected
$panel;
   
    protected function
Form_Create() {
       
$this->panel = new QPanel($this, 'panel');
       
$this->panel->AutoRenderChildren = true;
       
$this->panel->Visible = true;
       
$this->panel->RemoveChildControls( true );
       
       
$objpanel = new UploadPanel($this->panel, 'closePanel');
       
     }
}

class
MyDialog extends QDialogBox {
    public
$uplUploaderInDialog;
   
    public function
__construct($parentObj) {
       
parent::__construct($parentObj);
       
       
$this->uplUploaderInDialog = new QFileAsset($this);
       
       
$this->AutoRenderChildren = true;
    }
}

class
UploadPanel extends QPanel {
    public
$dlgDialog;
    public
$btnShow;
    public
$uplUploaderInForm;
   
    protected
$strClosePanelMethod;
   
    public function
__construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
           
// Call the Parent
           
try {
               
parent::__construct($objParentObject, $strControlId);
            } catch (
QCallerException $objExc) {
               
$objExc->IncrementOffset();
                throw
$objExc;
            }
           
           
$this->strTemplate = 'uploadpanel.tpl.php';
           
$this->strClosePanelMethod = $strClosePanelMethod;
           
           
$this->dlgDialog = new MyDialog($this);
           
$this->dlgDialog->Display = true;
       
       
$this->btnShow = new QButton($this);
       
$this->btnShow->Text = "click me";
       
$this->btnShow->AddAction(new QClickEvent(), new QAjaxAction("btnShow_click"));
       
       
$this->uplUploaderInForm = new QFileAsset($this);
}

public function
btnShow_Click($strFormId, $strControlId, $strParameter) {
       
$this->dlgDialog->ShowDialogBox();
    }
   
    public function
closePanel() {
        ;
    }
   
}

SampleForm::Run('SampleForm');
   
?>

image_edit.tpl.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php _p(QApplication::$EncodingType); ?>" />
<title>Sample QForm</title>
<style type="text/css">@import url("<?php _p(__VIRTUAL_DIRECTORY__ . __CSS_ASSETS__); ?>/styles.css");</style>
</head><body>

<?php $this->RenderBegin(); ?>
<? $this->panel->Render(); ?>
<br/>
<br/>
hello
<?php $this->RenderEnd(); ?>

</body></html>

uploadepanel.tpl.php:

<div id="formControls">
<?php
$_CONTROL
->dlgDialog->Render();
$_CONTROL->uplUploaderInForm->Render();

?>

</div>

So it seems my assumption that QFileAsset was not working in a panel is incorrect. However if I generate the code and use the default dashboard and add a QFileAsset to the edit panel (ImageEditPanel.class.php), the problem remains (i.e. first image or file upload fails ... all subsequent uploads succeed).

note: I have removed all buttons and references to meta controls etc.

class ImageEditPanel extends QPanel {
// Local instance of the ImageMetaControl

// Controls for Image's Data Fields
public $flaImage;

// Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References

// Other Controls

// Callback
protected $strClosePanelMethod;

public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
// Call the Parent
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}

// Setup Callback and Template
$this->strTemplate = 'ImageEditPanel.tpl.php';
$this->strClosePanelMethod = $strClosePanelMethod;

// Construct the ImageMetaControl
// MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent

// Call MetaControl's methods to create qcontrols based on Image's data fields
$this->flaImage = new QFileAsset($this);
// Create Buttons and Actions on this Form
...

If I add a QfileAsset to the main Dashboard Form, it works as expected:

class Dashboard extends QForm {
protected $lstClassNames;

protected $pnlTitle;
protected $pnlList;
protected $pnlEdit;

public $flaImage;

protected function Form_Create() {
$this->pnlTitle = new QPanel($this);
$this->pnlTitle->Text = 'AJAX Dashboard';

// $this->flaImage = new QFileAsset($this);
$this->pnlList = new QPanel($this, 'pnlList');
$this->pnlList->AutoRenderChildren = true;

$this->pnlEdit = new QPanel($this, 'pnlEdit');
$this->pnlEdit->AutoRenderChildren = true;
$this->pnlEdit->Visible = false;
...

As a side effect however, by doing this all other forms in the other panels which were not working properly previously now start working!!!!??!!?!?!

So I have hacked a solution to my problem by adding a QFileAsset to the Dashboard and not rending it. This seems to get IE to upload the file correctly on the first submission.

I am not happy with this solution but it's the only was I have been able to get the QFileAsset to work correctly in IE. Can someone in the know make any sense of what I or the default Dashboard is doing wrong? ... Please?

Offline
Joined: 04/06/2009

Sorry enzo,

Been busy on another project over the last couple of months, just getting back to this today

Offline
Joined: 04/06/2009

Anyone any idea? Surely I can't be the only person on the planet experiencing this issue? Maybe I am ... hmmmmm ...

Offline
Joined: 03/31/2008

Please respond to the ticket. If you come up with more feedback, and/or some example code that addresses the comments made there, we'll re-open it.

Offline
Joined: 04/06/2009

Ok will do

Offline
Joined: 03/16/2011

I want to add to this conversation that I have also encountered this problem in QCubed version 2.0.2 and used the same workaround, declaring a QFileControl on the QForm without rendering it fixes al my problems right away.

I used the forms generated by codegenerator to show a QPanel with a file upload. The files will not upload in IE (tested IE8).

So that makes my issue the exact same issue as is conversated about in this topic and its still a active bug!!!