- function invoice_perm()
- {
- return array('access content invoice');
- }
- function invoice_menu(
- {
- $items['invoice'] = array(
- 'title' => 'Invoice Entry',
- 'page callback' => 'invoice_editpage',
- 'access callback' =>'user_access',
- 'access arguments' => array('access content invoice'),
- 'type' => MENU_NORMAL_ITEM,
- );
- return $items;
- }
- function invoice_editpage()
- {
- $output = t('Invoice Entry Form.');
- // Return the HTML generated from the $form data structure.
- $output .= drupal_get_form('invoice_nameform');
- return $output;
- }
- function invoice_nameform($form_id, $form_state = NULL)
- {
-
- //File Refernce name
- $form['invoice_title'] = array(
- '#type' => 'textfield',
- '#title'=>t('Invoice Title'),
- '#size'=>20,
- );
- $form['#attributes'] = array('enctype' => "multipart/form-data");
- $form['invoicefileattachment'] = array(
- '#type' => 'file',
- '#title' => t('Browse the Scan copy of the invoice'),
- '#required' => FALSE,
- '#size'=>20,
- '#default_value' => $form_state['values']['invoicefileattachment'],
- );
- $form['submit1'] = array(
- '#type' => 'submit',
- '#value' => t('Register'),
- );
- return $form;
- }
- function invoice_nameform_submit($form_id, $form_state)
- {
- global $user;
- profile_load_profile($user);
- $uid=$user->uid;
- $empid=$user->employee_code;
- $userip = $_SERVER['REMOTE_ADDR'];
- $dt=date('Y-m-d H:i:s');
- $state_code=$user->state_code;
- if($state_code==30)
- $abc='TR';
- else
- $abc='TN';
- $limits = array () ;
- $invoice_title = $form_state['values']['invoice_title'];
- $po_title=$form_state['values']['po_title'];
- $path123=file_directory_path();
- $file = file_save_upload('invoicefileattachment', $validators, file_directory_path());
- $filename = $file->filename;
- $src = file_directory_path() . '/' . $filename;
- $dest = $abc.'/'.$filename;
- $path_file=$path123.'/'.$abc.'/'.$filename;
- if(isset($filename))
- {
- file_copy($src, $dest, FILE_EXISTS_REPLACE);
- file_delete($path123.'/'.$filename);
- drupal_set_message (" Invoice File saved", "status");
- file_set_status ($file, FILE_STATUS_PERMANENT);
- db_query("INSERT into drupal_txn_file_upload(uid ,
- filename,
- filepath,
- filesize,
- state_code,
- category,
- timestamp,title)
- VALUES('%d','%s','%s','%d','%d','%s','%d','%s')",$uid,$filename,$path_file,$file_size,$state_code,$category,time(),$invoice_title);
- }
This site will provide lot of information for all the internet users with details of shortcut techniques and many more........
Saturday, January 29, 2011
Uploading Files in Drupal
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment