How to upload a file to a folder location in drupal module way…
I am creating a module(sample) in that i want to create a n upload file so that it should be stored in a particular location(folder).. with out using cck pls help me … i coded like this
$form['pem_file_upload'] ['certificates'] = array (
'#type' => 'file',
'#value' => 'upload',
'#title' => t('upload your certificate file'),
'#description' => t('Upload the certificate file which is helpfull in sending push messages to ios device'),
'#default_value' => variable_get('certificates', ''),
);
variable_set('certificates', $form_state['values'] ['certificates']);
$form['pem_file_upload'] ['certificates'] = array (
'#type' => 'file',
'#value' => 'upload',
'#title' => t('upload your certificate file'),
'#description' => t('Upload the certificate file which is helpfull in sending push messages to ios device'),
'#default_value' => variable_get('certificates', ''),
);
variable_set('certificates', $form_state['values']['certificates']);
for saving the file itself this is the function you need
public:// is a streams format and points to sites/all/default/files
for more information see the drupal 7 file api