CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [terrykhatri531] How to implement a checkbox that will send data to db: Edit Log



terrykhatri531
User

Jul 16, 2014, 5:17 PM


Views: 63599
Re: [terrykhatri531] How to implement a checkbox that will send data to db

Hi guys,

I am trying to implement a photo upload routine using the following code which is resulting in an error as under :


Code
Permission denied at /usr/share/perlproj/cgi-bin/editphoto2.pl line 91.




And here is the relevant snippet of the script for uploading a photo :


Code
  
# get form parameters
my $q = new CGI;
my $action = $q->param('go');
my $empid = $q->param('empid');
my $upload_dir = "/usr/share/perlproj/cgi-bin/images";
my $filename = $q->param("photo");
my $safe_filename_characters = "a-zA-Z0-9_.-";
$CGI::POST_MAX = 1024 * 5000;

-----

# Upload photo
if ( $action eq "UPLOAD" ) {

if ( !$filename ) {
print $q->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}

my ( $name, $path, $extension ) = fileparse ( $filename, '..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;

if ( $filename =~ /^([$safe_filename_characters]+)$/ ) {
$filename = $1; }
else {
die "Filename contains invalid characters"; }

my $upload_filehandle = $q->upload("photo");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
binmode UPLOADFILE;


while ( <$upload_filehandle> ) {
print UPLOADFILE; }

close UPLOADFILE;

$msg = "Photo has been uploaded $upload_dir/$filename";
-----




The line in red is the offending one, the error msg is so brief its hard for me to guess what permission is being denied, but I am sure experienced gurus like you know what it means, the directory its being uploaded to has a -R 775 permission.

I am also attaching the whole script just in case you may want to have a look at it.

Many many thanks !!

Terry


(This post was edited by terrykhatri531 on Jul 16, 2014, 5:25 PM)
Attachments: editphoto2.pl (4.12 KB)


Edit Log:
Post edited by terrykhatri531 (User) on Jul 16, 2014, 5:25 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives