Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal 6 File Handling
    primarykey
    data
    text
    <p>I am handling file upload field in a form using Drupal 6 form APIs. The file field is marked as <strong>required</strong>. I am doing all the right steps in order to save and rename files in proper locations.</p> <p>upload form</p> <pre><code>$form = array(); .... $form['image'] = array( '#type' =&gt; 'file', '#title' =&gt; t('Upload photo'), '#size' =&gt; 30, '#required' =&gt; TRUE, ); $form['#attributes'] = array('enctype' =&gt; "multipart/form-data"); ... </code></pre> <p>form validate handler</p> <pre><code>$image_field = 'image'; if (isset($_FILES['files']) &amp;&amp; is_uploaded_file($_FILES['files']['tmp_name'][$image_field])) { $file = file_save_upload($image_field); if (!$file) { form_set_error($image_field, t('Error uploading file')); return; } $files_dir = file_directory_path(); $contest_dir = 'contest'; if(!file_exists($files_dir . '/' . $contest_dir) || !is_dir($files_dir . '/' . $contest_dir)) mkdir($files_dir . '/' . $contest_dir); //HOW TO PASS $file OBJECT TO SUBMIT HANDLER $form_state['values'][$image_field] = $file; file_move($form_state['values'][$image_field], $files_dir."/" . $contest_dir . "/contest-". $values['email']. "-" . $file-&gt;filename); } else { form_set_error($image_field, 'Error uploading file.'); return; } </code></pre> <p>On submiting form</p> <p>Form always reports an error <code>Upload photo field is required.</code> although files are getting uploaded. How to deal with this issue?</p> <p>How to pass file information to submit handler?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload