Permission Denied When Uploading Files Through CGI

Posted in: Blog, How To's, Perl, Web Development

I have a Perl script that one of my clients uses to upload files. It is a script that I created and has been working flawlessly for a couple of years now. Today I received a call saying that this client is no longer able to upload files.

When they tried to upload files to their server they received an error saying something to the effect of:

The server encountered an error. The script either created no output or an error. Check the logs.

Please excuse the paraphrasing, I did not capture a copy of the error but that is basically what it said. After checking the logs I noticed this error:

CGI open of tmpfile: Permission denied

This client uses iPower on a shared host to host their website. By the looks of this error it seems that they have changed something, perhaps tightened the permissions on the default temp folder that Perl uses.

There is a simple fix for this:

  1. Create a temp folder under your document root on your website. For example:
    /your-document-root/tmp
  2. Give it the proper permissions. You may have to play with this one start with 755 and work your way up. You may have to use 777 for some configurations.
  3. Add the following line to your Perl script somewhere near the top after any ‘use’ statements. For example:
    use CGI;
    $CGITempFile::TMPDIRECTORY = "/your-document-root/tmp";

That should take care of it. This fix definitely worked on the iPower configuration. Hope this helps some of you out there.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis
  • Yahoo! Buzz
  • YahooMyWeb
Leave a Reply

About This Site

WDBuc.com is the web site and blog of William D Buchanan, a web developer and technical consultant in the Tampa, Florida area. More...