pickup subdir from table and put into upload_subdir [message #1363] |
Fri, 06 June 2008 03:58 |
Jovan
Messages: 24 Registered: February 2008 Location: Serbia
|
Junior Member |
|
|
Hi Tony,
I have in my user table column upload_path, and I have a problem to read this in _cm_initialiseFileUpload function, and put in $this->upload_subdir field.
This is the sequence:
1. LIST1 of my custom table
2. Than select first row, and press read button
3. After that I press Upload button inside Read option
My demand is to pickup value of selected column upload_path and put in $this->upload_subdir inside _cm_initialiseFileUpload function.
I sow that Upload don't work with select option, but how to simulate it ?
Everything is o.k. when I put string in $this->upload_subdir.
I tried, and could not find solution.
Jovan
|
|
|
|
|
|
|
|
Re: pickup subdir from table and put into upload_subdir [message #1373 is a reply to message #1372] |
Thu, 12 June 2008 04:56 |
AJM
Messages: 2369 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
When I pointed you to that link I did not mean that you had to call the _cm_getForeigndata() method, I meant that you could use that code sample within your _cm_initialiseFileUpload() method.
You can access any other table from anywhere in your code with the following:
$dbobject =& singleton::getInstance('other_table');
$dbobject->sql_select = 'other_field';
$other_data = $dbobject->getData("other_id='whatever'");
What you do with the contents of $other_data is up to you.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Re: pickup subdir from table and put into upload_subdir [message #1561 is a reply to message #1560] |
Thu, 21 August 2008 19:57 |
ikatz
Messages: 40 Registered: December 2007 Location: Durham, NH
|
Member |
|
|
Actually -- and this is slightly embarassing -- at the time that I wrote the last post, I had only verified that the fieldarray would contain the primary key that I needed (to set the upload directory), and I had not attempted to upload the file into that directory.
As it turns out, when you submit an uploaded file, _cm_initialiseFileUpload() will be called a second time -- and the fieldarray will be empty. I ended up having to do the above hack for both the upload and picker transactions in order to make them work as I intended.
So, to answer your question, I definitely would feel more comfortable if this data was provided directly (vs my workaround), but it would be your call on how best to do it. Having an argument called "fieldarray" might be misleading, as it would need to access the fieldarray from the previous transaction. I'm not sure what the implications are here, but it almost seems like there could be separate functions that get called, one initialization for entering the file upload and one for leaving it with the submitted file.
[Updated on: Thu, 21 August 2008 20:05] Report message to a moderator
|
|
|
Re: pickup subdir from table and put into upload_subdir [message #1562 is a reply to message #1561] |
Fri, 22 August 2008 04:57 |
AJM
Messages: 2369 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You are incorrect when you say that _cm_initialiseFileUpload() will be called a second time when you submit an uploaded file. It is only called when the component is first activated. When you submit a file name it is the _cm_fileUpload() method which is called.
Calling the argument "$fieldarray" should not be misleading as that is the generic name that is used for an associative array. If you automatically assume that this is the contents of $fieldarray in the calling task then your assumption is incorrect - it is only the $where string which is passed from the parent to the child task, and this string is then converted into an associative array.
Although by default the $where string which is extracted from a parent object and passed to a child object is the primary key of the parent object, it is possible to modify it at the point of extraction. For example, if the filepicker is activated from a POPUP button then $where can be set to whatever you like in the _cm_popupCall() method.
I have changed std.filepicker1.inc so that it is passed the $where string from the parent task, and this string is therefore available to be passed from the filepicker to the fileupload task. This will then be available in both the _cm_initialiseFileUpload() and _cm_fileUpload() methods.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|