Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » File picker
File picker [message #368] Tue, 07 November 2006 12:07 Go to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Hi All,
I am able to select a picture from a subdir but have some problems for doing the same with word documents from a subdirectory. Please help.

Abdou


Abdou Salam
Re: File picker [message #370 is a reply to message #368] Tue, 07 November 2006 12:52 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
What problems, exactly?

Re: File picker [message #372 is a reply to message #370] Wed, 08 November 2006 04:49 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
For uploading word and/or pdf documents, my question is where to declare :
- the upload subdirectory
- the file type
- the maximum file size ?


Abdou Salam
Re: File picker [message #373 is a reply to message #372] Wed, 08 November 2006 05:12 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
A good place to start might be to locate the working example that is included in the Radicore download and to copy that.

Assuming that you have a development environment that contains ALL the framework code, including ALL the prototype applications, you can find a working example of every transaction pattern by gong to home->menu system->pattern, select the pattern you want, then press the "Tasks" button to list all tasks that use that pattern.

Also, if you look in the radicore/default directory you will see skeleton scripts for every pattern. These are the scripts that are referenced in the recently released script generation function.

Just a note, though. I am changing the way that the filepicker pattern is implemented in the next release, but it will be documented in the tutorial.


Re: File picker [message #374 is a reply to message #373] Wed, 08 November 2006 07:19 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Below is what is specified in xample

$fieldspec['picture']= array('type' => 'string',
'size' => 40,
'subtype' => 'image',
'imagewidth' => 75,
'imageheight' => 95,
'control' => 'filepicker',
'task_id' => 'x_personfilepicker)');

This example is for uploading picture but for Word or PDF documents I must specify the following :

$subdir = $fileobject->upload_subdir;
$filetypes = $fileobject->upload_filetypes;
$maxfilesize = $fileobject->upload_maxfilesize;



Abdou Salam
Re: File picker [message #375 is a reply to message #374] Wed, 08 November 2006 07:58 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Sorry, let me ask more clearly what are the other accepted file types for file picker ? I have submitted 'application/msword' and it is not working.



Abdou Salam
Re: File picker [message #376 is a reply to message #374] Wed, 08 November 2006 08:02 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
You are not looking in the right place. The script 'std.fileipload1.inc' calls the initialiseFileUpload() method which in turn calls the _cm_initialiseFileUpload() method in your application table class. This is where you specify the parameters, such as:
function _cm_initialiseFileUpload ($fieldarray)
// perform any initialisation before displaying the File Upload screen.
{
    $this->upload_subdir      = 'pictures';
    $this->upload_filetypes   = array('image/x-png', 'image/gif');
    $this->upload_maxfilesize = 100;

    return $fieldarray;

} // _cm_initialiseFileUpload


Re: File picker [message #377 is a reply to message #375] Wed, 08 November 2006 08:12 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
You keep switching between the filepicker and fileupload patterns, which is very confusing. They are different patterns to do different things, and so the parameters are different.

To create a filepicker the component script needs to look something like this:
<?php
$screen   = 'person.filepicker.screen.inc'; // file identifying screen structure
$subdir   = 'whatever';                     // subdirectory
$filetype = 'document';                     // file types to process

require 'std.filepicker1.inc';              // activate page controller
?>

At the moment the script std.filepicker.inc does not recognise the file type of 'document', so you will have to change it as follows:
switch ($filetype) {
    case 'image':
        $filemask = "(\.gif|\.jpg|\.png|\.bmp)$";
        break;
    case 'document':
        $filemask = "(\.pdf|\.doc)$";
        break;
    default:
        $errors[] = getLanguageText('sys0059', $filetype); // "Unknown filetype ($filetype)"
} // switch

I am going to change this in the next release so it will be easier.


Re: File picker [message #378 is a reply to message #377] Wed, 08 November 2006 09:17 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Many thanks for quick support.


Abdou Salam
Re: File picker [message #379 is a reply to message #378] Wed, 08 November 2006 09:36 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
No problem. I hope my replies are good enough for you to get your scripts working.

Re: File picker [message #380 is a reply to message #379] Wed, 08 November 2006 11:03 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Yes. It is working now. I'm picking fine documents.
For file download I have this message : No file specified for download.
Where to specify a file for download ? It is the same file that I was able to pick lastly. Now, in a LIST2 I select a record containing the picked file. When I press a navigation button "Download Attachment" I get the above mentioned message.




Abdou Salam
Re: File picker [message #382 is a reply to message #380] Wed, 08 November 2006 11:23 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
You are getting that message because you have not specified which file to download.

Take a look in script radicore/xample/person_filedownload.php for a working example. It uses subclass x_person_s01 which contains the following code in the _cm_post_getData() method:
function _cm_post_getData ($rows, &$where)
// perform custom processing after database record(s) are retrieved.
// NOTE: $where is passed BY REFERENCE so that it may be modified.
{
    // specify which file is to be downloaded
    foreach ($rows as $rownum => $rowdata) {
       	$rows[$rownum]['download_filename'] = $rowdata['picture'];
      	// 'inline' does not give any option to save
        //$rows[$rownum]['download_mode'] = 'inline';
    } // foreach

    return $rows;

} // _cm_post_getData


All this is described in http://www.tonymarston.net/php-mysql/dialog-types.html#filed ownload.


Re: File picker [message #384 is a reply to message #382] Wed, 08 November 2006 12:17 Go to previous message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Wonderful !
It is working perfectly.
Warm regards.




Abdou Salam
Previous Topic: std.list3 problem
Next Topic: std.list3 passing middle table to child form
Goto Forum:
  


Current Time: Wed Nov 27 00:09:53 EST 2024

Total time taken to generate the page: 0.01574 seconds