How to verify if a file is selected on step 4 of article submission

Hi,
In the 4th step of article submission if the author presses the upload button without selecting a file, a supplementary file with no name or size could be added to the article.
How can I verify if the author has actually selected a file, before redirecting him to the supplementary file form?
the red square in the below image displays the blank field.
This is from OJS 2.4.8

Thanks,

This will be handled by:

See particularly case 4:.

Thank you @ctgraham,
your responses are really appreciated.
I got to this point but I am unable to get the file information from the ‘file upload control’.
I thought it is an array and tried:

$fileSpec = $request->getUserVar('submitUploadSuppFile'); $fileName = $fileSpec['filename']; $fileSize = $fileSpec['size']; ...

I also tried:
$fileName = $fileSpec->getName(); $fileSize = $fieSpec->getSize(); ...

but is not working.
could you help me on this item?
Best,
Ali

Hi @ctgraham,
I was checking AuthorSubmitSuppFileForm.inc.php and I found this in line 196:

else {
            // Upload file, if file selected.
            if ($articleFileManager->uploadedFileExists($fileName)) {
                $fileId = $articleFileManager->uploadSuppFile($fileName);
            } else {
                $fileId = 0;
            }

            // Insert new supplementary file
            $this->suppFile = new SuppFile();
            $this->suppFile->setArticleId($this->articleId);
            $this->suppFile->setFileId($fileId);

            parent::execute();

            $this->setSuppFileData($this->suppFile);
            $suppFileDao->insertSuppFile($this->suppFile);
            $this->suppFileId = $this->suppFile->getId();
        }

it is checking if the file exists but it seems to insert the new submission file anyway!
I changed it to:

else {
            // Upload file, if file selected.
            if ($articleFileManager->uploadedFileExists($fileName)) {
                $fileId = $articleFileManager->uploadSuppFile($fileName);
            } else {
                $fileId = 0;
            }


            if($fileId != 0){
                // Insert new supplementary file
                $this->suppFile = new SuppFile();
                $this->suppFile->setArticleId($this->articleId);
                $this->suppFile->setFileId($fileId);

                parent::execute();

                $this->setSuppFileData($this->suppFile);
                $suppFileDao->insertSuppFile($this->suppFile);
                $this->suppFileId = $this->suppFile->getId();
            }
        }

Problem is solved and empty files are no more uploaded. Can you confirm that this is correct?

Thanks

I think the assumption of the original code is that you may want to create a “placeholder” for a supplemental file upload (describing it before adding it).

You code should effectively prevent adding the stub if no file is uploaded.

Thank you @ctgraham,
I just wanted to make sure I did not mess up anything.

Best,
Ali