Purchase : test $_FILES before trying to save file

This commit is contained in:
sparkyx 2025-10-06 16:37:32 +02:00
parent 9f3e308a21
commit 067434e520
2 changed files with 4 additions and 2 deletions

View file

@ -262,6 +262,9 @@ class Acc_Document extends Document {
/**
* pj is the $_FILES key
*/
if ( $_FILES['pj']['name']=="") {
return false;
}
$a_file= $this->db->upload('pj',only_oid:false);
if ($a_file == false) {
return false;

View file

@ -1052,9 +1052,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger
}
/* Save the attachment */
if ( isset ($_FILES))
if ( isset ($_FILES) && sizeof($_FILES) != 0 && $_FILES["pj"]["name"] != 0 )
{
if ( sizeof($_FILES) != 0 )
$acc_document=new \Acc_Document($this->db, $this->jr_id);
$acc_document->save_receipt();
$this->doc=HtmlInput::show_receipt_document($this->jr_id,h($_FILES['pj']['name']));