Possible 6.1.1 problem with images

Talk about Image/File fields (uploading, problems etc.)

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

Possible 6.1.1 problem with images

Postby daviddelmonte » Sep 25th, '10, 15:02

I have not changed my code, but when I try to add a record, I cannot seem to upload an image.

I have an image folder. Before 6.1.1, I had no issues uploading and viewing images.

In 6.1.1, I can view existing images. However, when I try to add an image (to a new record), when I select "upload", the entire record is validated as if I selected "submit".

Has anything changed?

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Possible 6.1.1 problem with images

Postby administrator » Sep 26th, '10, 11:11

We'll check this issue. thanks.

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Possible 6.1.1 problem with images

Postby administrator » Sep 26th, '10, 15:08

Here the fix:

1. In Datagrid.class change PrintHiddenFieldsFromUrl() with following:

Code: Select all

    protected function PrintHiddenFieldsFromUrl($curr_url){
        if($this->methodPostBack != "get"){
            $curr_url_temp = str_replace("?", "", $curr_url);
            $curr_url_temp = str_replace("&", "&", $curr_url_temp);
            parse_str($curr_url_temp, $curr_url_pairs);
            foreach($curr_url_pairs as $key => $val) {
                echo "<input type='hidden' name='".$key."' id='".$key."' value='".$val."' />".chr(13);
            }
        }       
    }


2. in scriptss/dg.js change formAction() with following:

Code: Select all

function formAction(file_act, file_id, unique_prefix, http_url, query_string, postback_method, mode){
   var unique_prefix = (unique_prefix==null) ? "" : unique_prefix;
   var http_url      = (http_url==null) ? "" : http_url;
   var query_string  = (query_string==null) ? "" : query_string;
   var postback_method = (postback_method==null) ? "get" : postback_method;
   var mode            = (mode==null) ? "edit" : mode;

   if(postback_method == "post" || postback_method == "ajax"){
      if(file_act == "" && file_id == ""){
         document.getElementById(unique_prefix+'mode').value = mode;
         document.getElementById(unique_prefix+'frmEditRow').action=http_url;     
      }else{
         document.getElementById(unique_prefix+'mode').value = mode;         
         var input = document.createElement('input'); input.setAttribute('type', 'hidden'); input.setAttribute('name', unique_prefix+"file_act"); input.setAttribute('id', unique_prefix+"file_act"); input.setAttribute('value', unescape(file_act));
         document.getElementById(unique_prefix+'frmEditRow').appendChild(input);
         var input = document.createElement('input'); input.setAttribute('type', 'hidden'); input.setAttribute('name', unique_prefix+"file_id"); input.setAttribute('id', unique_prefix+"file_id"); input.setAttribute('value', unescape(file_id));
         document.getElementById(unique_prefix+'frmEditRow').appendChild(input);
         document.getElementById(unique_prefix+'frmEditRow').action=http_url;
      }
   }else{
      if(file_act == "" && file_id == ""){
         document.getElementById(unique_prefix+'frmEditRow').action=http_url+"?"+query_string;           
      }else{
         document.getElementById(unique_prefix+'frmEditRow').action=http_url+"?"+query_string+((query_string!="")?"&":"")+unique_prefix+"file_act="+file_act+"&"+unique_prefix+"file_id="+file_id;           
      }
   }

   document.getElementById(unique_prefix+'frmEditRow').encoding='multipart/form-data';
   document.getElementById(unique_prefix+'frmEditRow').method='POST';
   document.getElementById(unique_prefix+'frmEditRow').submit();
}


3. Clean cache of your browser and try again.

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

Re: Possible 6.1.1 problem with images

Postby daviddelmonte » Sep 26th, '10, 16:40

Hi I changed the code in the 2 files as you suggested (I copied and pasted the code), but I still get the same results, both with add record and edit record..

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Possible 6.1.1 problem with images

Postby administrator » Sep 27th, '10, 08:08

The new syntax is:
"on_js_event"=>"onchange='formAction(\"\", \"\", \"".$dgrid->uniquePrefix."\", \"".$dgrid->HTTP_URL."\", \"".$_SERVER['QUERY_STRING']."\", \"post\", \"".$_REQUEST[$dgrid->uniquePrefix.'mode']."\")'"

where instead of "post" you have to write appropriate postback method you work with: post, get or ajax.

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

Re: Possible 6.1.1 problem with images

Postby daviddelmonte » Sep 27th, '10, 10:22

Thanks for the help. It works, but I get an error message:

Notice: Undefined index: ng_mode in mycode.php on line ...

Code 1:

Code: Select all

# *** defines postback submission method for DataGrid: AJAX, POST or GET(default)
$postback_method = 'ajax';
$dgrid->SetPostBackMethod($postback_method);   


Code 2:

Code: Select all

$unique_prefix = "ng_"; 

Code 3:

Code: Select all

// IMAGE THUMBNAIL

"image" => array("header"=>"Image", "type"=>"image", "req_type"=>"sy", "align"=>"left", "width"=>"300px",  "on_js_event"=>"onchange='formAction(\"\", \"\", \"".$dgrid->uniquePrefix."\", \"".$dgrid->HTTP_URL."\", \"".$_SERVER['QUERY_STRING']."\", \"ajax\", \"".$_REQUEST[$dgrid->uniquePrefix.'mode']."\")'", "target_path"=>"../uploads/", "image_width"=>"75px", "image_height"=>"75px", "magnify"=>"true", "magnify_type"=>"magnifier", "magnify_power"=>"3"),

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Possible 6.1.1 problem with images

Postby administrator » Sep 28th, '10, 09:46

Where exactly? Here: $_REQUEST[$dgrid->uniquePrefix.'mode']?
so you have to check it before use, for example:

$xxx= isset($_REQUEST[$dgrid->uniquePrefix.'mode']) ? $_REQUEST[$dgrid->uniquePrefix.'mode'] : "";

and then replace $_REQUEST[$dgrid->uniquePrefix.'mode'] with $xxx

chirng
Master
Master
Posts: 148
Joined: Jun 7th, '09, 04:15

Re: Possible 6.1.1 problem with images

Postby chirng » Nov 4th, '10, 08:39

i have the same problem... :?

the only workable way now is disable the ajax......8(

# *** defines postback submission method for DataGrid: AJAX, POST or GET(default)
//$postback_method = 'ajax';
//$dgrid->SetPostBackMethod($postback_method);

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

Re: Possible 6.1.1 problem with images

Postby daviddelmonte » Nov 4th, '10, 11:16

I'm interested in a resolution. I had to revert to 6.0.8

Perhaps if Admin could give us a complete example of how to make this work?

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Possible 6.1.1 problem with images

Postby administrator » Nov 4th, '10, 12:51

How do you want to use on_js_event"=>"onchange='......' in inage fields?


Return to “Field type: "image/file"”