I have the following code in my form.
function video_subtitles_menu() { //print "video_subtitles_menu 1";exit; $items = array(); $items['video_subtitles_test/upload'] = array( //this creates a URL that will call this form at "examples/form-example" 'title' => 'Upload Subtitle', //page title 'description' => 'Uploading subtitle for videos', 'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed. for a form, use drupal_get_form 'page arguments' => array('video_upload_subtitles_form'), //put the name of the form here 'access callback' => TRUE ); //print "video_subtitles_menu 2";exit; return $items; }
function video_upload_subtitles_form($form, &$form_state) { $form = array('#attributes' => array('enctype' => 'multipart/form-data')); $form['video_name'] = array( '#title' => t('Name Of the video'), '#type' => 'textfield', ); $form['sub_file'] = array( '#type' => 'file', '#title' => t('Upload video'), '#size' => 48, '#description' => t('Pick a video file to upload.'), ); $form['submit_button'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }
function video_upload_subtitles_form_validate() { if(!file_check_upload('upload')) { // If you want to require it, you'll want to do it here... something like this: form_set_error('upload', 'File missing for upload.'); } }
function video_upload_subtitles_form_submit($form, &$form_state) { $video_name = $form_state['values']['video_name'];//I am able to get this $file = file_save_upload('sub_file', array()); print "<pre>";print_r($file);// no response here drupal_set_message(t('The form has been submitted.'));//this also not printing }
On the submission handler, it only returns the text field, I don`t get anything from file upload field, when I use file_save_upload.
This is the response which i get in firebug
, I have tried uploading text and excel file.
What I am trying to do is create a block where you can upload a file than I need to get the url to upload it to CDN
but how to get the link of file at form submission.
I am using Drupal 7
by the way.