tags:

views:

54

answers:

2

I am using CGI.pm version 3.10 for file upload using Perl. I have a Perl script which uploads the file and one of my application keeps track of different revisions of the uploaded document with check-in check-out facility.

Re-creational steps:

  • I have done a checkout(download a file) using my application (which is web based uses apache).
  • Logout from current user session.
  • Login again with same credentials and then check-in (upload) a new file.

Output:

  • Upload successful
  • Perl upload script shows the correct uploaded data
  • New revision of the file created

Output is correct and expected except the one case which is the issue

Issue:

  • The content of the newly uploaded file are same as the content of the last uploaded revision in DB.

I am using a temp folder for copying the new content and if I print the new content in upload script then it comes correct. I have no limit on CGI upload size. It seems somewhere in CGI environment it fails might be the version i am using. I am not using taint mode.

Can anybody helps me to understand what might be the possible reason?

+1  A: 

Sounds like you're getting the old file name stuck in the file upload field. Not sure if that can happen for filefield but this is a feature for other field types.

Try adding the -nosticky pragma, eg, use CGI qw(-nosticky :all);. Another pragma to try is -private_tempfiles, which should prevent the user from "eavesdropping" even on their own uploads.

Of course, it could be that you need to localize (my) some variable or add -force to the filefield.

igelkott
A: 

I found the issue. The reason was destination path of the copied file was not correct, this was because my application one of event maps the path of copied file to different directory and this path is storing in user session. This happens only when I run the event just before staring upload script. This was the reason that it was hard to catch. As upload script is designed to pick the new copied file from same path so it always end up uploading the same file in DB with another revision. The new copied file lying in new path.

Solved by mapping correct path before upload.

Thanks

ppant