Failure to Upload File And Submit Form

I have a view defined with a CActiveForm, containing several drop down lists, text fields and a CMultiFileUpload widget. If a file is browsed and selected that is 11 Mb in size (presumably too large), it is displayed in the form, but when submitted, the form does not get conveyed back the controller action (no content in _POST) and the file name does not appear in the CUploadedFile object in the controller action. How do I detect that a file upload has failed (so as to inform the user), and can the rest of the form still be conveyed even if the file upload fails?

post your controller code here

My form contains, among other dropdowns and text boxes, a CMultiFileUpload entry that looks like this:

<?php $this->widget(‘CMultiFileUpload’, array(

                'name' =&gt; 'images',


                'duplicate' =&gt; 'File already selected&#33;',


                'htmlOptions'=&gt;array(


                'class'=&gt;'form-control'


                ),

));

Here’s my condensed controller code:

    public function actionUpdate(&#036;id)


    {


            //echo print_r(&#036;_POST); //exit; //debugging


           


            &#036;model=&#036;this-&gt;loadModel(&#036;id);





            // Uncomment the following line if AJAX validation is needed


            // &#036;this-&gt;performAjaxValidation(&#036;model);





            if(isset(&#036;_POST['Arts']))


            {


                  //DO ALOT OF APPLICATION-LEVEL STUFF WITH THE MODEL, THEN





                   if(&#036;model-&gt;save()){





                            &#036;images=CUploadedFile::getInstancesByName('images');


                            if (isset(&#036;images) &amp;&amp; count(&#036;images) &gt; 0){


                                    foreach (&#036;images as &#036;image =&gt; &#036;pic){


                                        if (&#036;pic-&gt;hasError)


                                        {   &#036;fileMsg .= &quot;ERROR: &#036;pic-&gt;name yields&quot;;


                                                &#036;fileMsg .= &#036;pic-&gt;getError();


                                                &#036;fileMsg .= &quot; &lt;br&gt;&quot;;


                                        }


                                        else


                                        {


                                           &#036;img_add=new ProjectDocs();


                                            if (&#036;pic-&gt;saveAs(Yii::app()-&gt;basePath.'/ProjectDocs/'.&#036;pic-&gt;name)){


                                                    &#036;img_add-&gt;arts_id = &#036;model-&gt;Request_id;


                                                    &#036;img_add-&gt;project_id = &#036;model-&gt;ProjectName_id;


                                                    &#036;img_add-&gt;FileName = &#036;pic-&gt;name;


                                                    &#036;img_add-&gt;save();


                                            }


                                            else


                                            {       &#036;fileMsg .= &quot;ERROR: &#036;pic-&gt;name FAILED TO UPLOAD &lt;br&gt;&quot;;


                                            }





                                        }


                                    }


                                }


                            }





                  // DO SOME MORE APPLICATION STUFF, THEN





                  &#036;this-&gt;redirect(array('admin','fileMsg'=&gt;&quot;&#036;fileMsg&quot;));





                    


            }





            &#036;this-&gt;render('update',array(


                    'model'=&gt;&#036;model,


            ));


    }

So, when I attempt to load a small file (< 8 Mb), it works fine without error, the _POST structure contains the populated form element, the file appears in the upload directory and the form is processed properly. The problem occurs when I attempt to load an 11 Mb file (one that is apparently too large), with or without other form fields populated. In this case, the _POST structure is empty and the action falls through to simply repaint the screen. The user is unaware that the file did not upload and the form was not processed.

In an attempt to notify the user of a file upload failure, since _POST is null in that case, I added the same CUploadedFile block of logic above the isset($_POST[‘Arts’])) condition. But, the hasError property and getError function of the CUploadFile object yield nothing for the file that failed.

Question: Is there a way to check and report that a file upload has failed and still process the remaining fields in the form?

Sorry the left margin white space disappears when viewing in the forum. If you attempt a reply to my message with the code, you can see the indentation, making the code much easier to read.