I am trying to set the status of an uploaded file to 1 but looking in the file_managed table it stays 0. The file does get uploaded properly but gets removed after a while.
My form field:
$form['nor'] = array(
'#type' => 'file',
'#title' => 'Upload pdf',
);
And my function:
function mymodule_addForm_submit($form, &$form_state) {
$nor = file_save_upload('nor', null, 'public://docs');
if ($nor){
$nor->status = FILE_STATUS_PERMANENT;
file_save($nor);
}
}
Debug of $nor:
stdClass::__set_state(array(
'uid' => '1',
'status' => 0,
'filename' => 'my_file.pdf',
'uri' => 'public://docs/my_file.pdf',
'filemime' => 'application/pdf',
'filesize' => 57930,
'source' => 'nor',
'destination' => 'public://docs/my_file.pdf',
'timestamp' => 1363198206,
'type' => 'default',
'fid' => '148',
'field_license' =>
array (
'und' =>
array (
0 =>
array (
'value' => 'nothing',
),
),
),
)
)
What am I doing wrong here?
$nor->fid
?