You are viewing the PKP Support Forum | PKP Home Wiki

Error Handling on File Upload (Author Submission Step2)

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
What to do if you have a technical problem with OCS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Error Handling on File Upload (Author Submission Step2)

Postby eagleeye » Fri Aug 19, 2011 11:10 pm

In my conference, I do not want to have the same papers uploaded more than once.
Here's what i've done so far:

- in the table 'paper_files', I have set the 'original_file_name' column to be UNIQUE
- in AuthorSubmitStep2Form.php, I have added this line (so that when there is a file uploaded for a second time, I would see Step 2 of Author Submission loaded again with an error message) :
Code: Select all
$this->addCheck(new FormValidatorCustom($this, 'submissionFile', 'required', 'author.submit.form.titleExists', array(DAORegistry::getDAO('PaperFileDAO'), 'paperFileExists'), array(), true));

- also i have added this function to PaperFileDAO.php :
Code: Select all

   function paperFileExists($originalFileName, $fileId = null, $allowDisabled = true) {
   $result =& $this->retrieve(
         'SELECT COUNT(*) FROM paper_files WHERE original_file_name = ?' . (isset($userId) ? ' AND file_id != ?' : '') . ($allowDisabled?'':' AND disabled = 0'),
         isset($fileId) ? array($originalFileName, (int) $fileId) : array($originalFileName)
      $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;


      return $returner;

But I still cannot return to Step 2 of Submission process when there is such error.
The page i get, is a page with only this error message on:
DB Error: Duplicate Entry for "xxxx.doc" for key 2.

Have I done all the required things?
Anyone know what else i need to do?
Posts: 4
Joined: Fri May 20, 2011 5:38 am

Re: Error Handling on File Upload (Author Submission Step2)

Postby mcrider » Mon Aug 29, 2011 1:28 pm

Hi eagleeye,

You should do a var_dump on the $originalFileName parameter -- I'm not sure what you have getting passed to your paperFileExists method is actually the original file name. You might have to grab the name of the file being uploaded from the $_FILES global array. In general, your code looks fine, but you'll have to do a bit of debugging in your validation method to see whats actually going on.

Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 2 guests