I have a form with a file upload widget:
$form['myFile'] = array(
'#tree' => false,
'#type' => 'file',
'#title' => t('Choose a file')
);
In the form validation handler, I upload the file and validate it with:
$validators = array(
"file_validate_extensions" => array(variable_get("allowed_extensions")),
"file_validate_size" => array(variable_get("max_image_size"))
);
$file = file_save_upload('myFile', $validators);
$form_state['file_storage']['myFile'] = $file;
Then, in the submit handler, I save the file using:
$file = $form_state['file_storage']['myFile'];
file_save($file);
This seems to work fine as I can find an entry for the file in the file_managed
table:
+-----+-----+--------------+-----------------------------+------------+----------+--------+------------+
| fid | uid | filename | uri | filemime | filesize | status | timestamp |
+-----+-----+--------------+-----------------------------+------------+----------+--------+------------+
| 49 | 1 | download.jpg | temporary://download.jpg | image/jpeg | 5410 | 0 | 1350312114 |
+-----+-----+--------------+-----------------------------+------------+----------+--------+------------+
The problem is that I can't find the file anywhere on disk:
$ su -
Password:
# updatedb
# locate download.jpg
/home/me/Pictures/download.jpg
As you can see, the only download.jpg
found is the one in my pictures folder which I passed into the form. I can't find anything on the server (in /var/www/
). So where is the file? Is it a BLOB in the drupal database? Has it simply not been uploaded properly? If so, what did I do wrong?