How can I send my parameters to handleUpload() function

Discuss MySQL Ajax Table Editor Pro Version

How can I send my parameters to handleUpload() function

Postby Atara » Wed Feb 07, 2018 10:07 am

I have URL parameters in the page, but they are not available in handleUpload()

If I watch $_SERVER, I can see them in the HTTP_REFERER, but not in REQUEST_URI:

Code: Select all
    [HTTP_REFERER] => http://mySite.com/myDir/mate_file.php?cid=101&tid=1
    [REQUEST_URI] => /myDir/mate_file.php
    [QUERY_STRING] =>    (no value here!)


so How can I send my parameters in the URL, or as regular parameters to handleUpload() , in addittion to the other parameters. e.g.
Code: Select all
handleUpload($col, $id, $filesArr, $valErrors, myAdditionalParameters)
Atara
 
Posts: 12
Joined: Wed Jul 26, 2017 9:01 am

Re: How can I send my parameters to handleUpload() function

Postby mukeshdak » Mon Mar 05, 2018 5:12 pm

mukeshdak
 
Posts: 30
Joined: Fri May 11, 2012 3:18 pm

Re: How can I send my parameters to handleUpload() function

Postby Atara » Mon Mar 12, 2018 8:51 am

thanks. I guess it would work.

but why HTTP_REFERER URL contains the parameters, while the current page does not contain them?
Did it opened a new page for upload? if so, how can I pass more parameters to the opened page?
Atara
 
Posts: 12
Joined: Wed Jul 26, 2017 9:01 am

Re: How can I send my parameters to handleUpload() function

Postby mukeshdak » Sun Apr 15, 2018 3:41 pm

REQUEST_URI and HTTP_REFERER both is working well in provided solution.
add following code in the beginning of the handleUpload function

Code: Select all
$temp = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
      $temp = explode("=", $temp);
      $ru = $temp[1];
      // Save this to last name.

instead of
Code: Select all
$ru=$_SERVER['REQUEST_URI'];


for live demo, click on the link below and then upload a file, this will show first passed parameter in last name column of the table.

http://mate.mukeshdak.com/UploadToDir.php?ln=Atara
mukeshdak
 
Posts: 30
Joined: Fri May 11, 2012 3:18 pm

Re: How can I send my parameters to handleUpload() function

Postby Atara » Mon Apr 16, 2018 11:38 am

Thanks.
HTTP_REFERER do contain the parameters, while REQUEST_URI does not.
so how can I add more parameters to handleUpload() function? I only manage to use the parameters that were sent to the original page.

e.g in your example, where in the code can I add "ln=Atara" parameter?
Atara
 
Posts: 12
Joined: Wed Jul 26, 2017 9:01 am

Re: How can I send my parameters to handleUpload() function

Postby mukeshdak » Mon Apr 16, 2018 5:53 pm

Multiple parameters can be passed and processed as

http://mate.mukeshdak.com/UploadToDir.p ... rict=Ajmer

Code: Select all
parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $param);
// Now  $param['state']  value will be Rajasthan


So in this fashion multiple parameters can be passed.
mukeshdak
 
Posts: 30
Joined: Fri May 11, 2012 3:18 pm

Re: How can I send my parameters to handleUpload() function

Postby Atara » Tue Apr 17, 2018 1:08 pm

I probably did not explain my question:

in the following code, where and how, can I add my parameters to handleUpload function?

Code: Select all
      $tableColumns['wrc_photo_' . 'fr'] = array(
         'display_text' => 'Photo' . ' (' . 'fr' . ')',
         'file_upload' => array(
            'upload_fun' => array(&$this, 'handleUpload'),
            'delete_fun' => array(&$this, 'handleDeleteFile')),
         'table_fun' => array(&$this, 'formatImage'),
         'view_fun' => array(&$this, 'formatImage'),
         'maxlen'   => 50,
         'perms' => 'EVCTAXQSHOF'
      );
Atara
 
Posts: 12
Joined: Wed Jul 26, 2017 9:01 am

Re: How can I send my parameters to handleUpload() function

Postby mukeshdak » Tue Apr 17, 2018 5:14 pm

Parameters need not to be passed through handleUpload function.

Parameters can be uploaded through other columns in MySql table ( via other fields )
mukeshdak
 
Posts: 30
Joined: Fri May 11, 2012 3:18 pm


Return to Pro Version

Who is online

Users browsing this forum: No registered users and 2 guests

cron