SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no such file or folder

    I was looking for an easy way to upload photo's on to a website. I ran across an article UPLOADING FILES USING CGI AND PERL on site point.

    I copied and pasted all the iformation to my text editor and changed the paths to what they needed to be and created the directories like the article stated however when I run the script I get Software error:
    No such file or directory at /home/users/web/b2096/ipg.itsonlykinkythefirst/cgi-bin/fileuploadscript.cgi line 39.
    I am not sure what file or folder name it is looking for can someone help me out on this? Here is the script that I can access on my server.

    Code Perl:
    #!/usr/bin/perl -wT
     
    use strict;
    use CGI;
    use CGI::Carp qw ( fatalsToBrowser );
    use File::Basename;
     
    $CGI::POST_MAX = 1024 * 5000;
    my $safe_filename_characters = "a-zA-Z0-9_.-";
    my $upload_dir = "/home/www.itsonlykinkythefirsttime.com/htdocs/upload";
     
    my $query = new CGI;
    my $filename = $query->param("photo");
    my $email_address = $query->param("email_address");
     
    if ( !$filename )
    {
    print $query->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 = $query->upload("photo");
     
    open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
    binmode UPLOADFILE;
     
    while ( <$upload_filehandle> )
    {
    print UPLOADFILE;
    }
     
    close UPLOADFILE;

    I am sure it is something simple I just can not figure it out. Thanks for your help.
    Last edited by Mittineague; Dec 23, 2013 at 02:27. Reason: reformatting bbcode tags

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    The error message states that the directory does not exist.

    Try this:
    Code:
    print getcwd();
    http://perldoc.perl.org/Cwd.html#getcwd-and-friends
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  3. #3
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is this? I am a learner of php. Can you describe me what is the code for?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    Current Working Directory

    Quote Originally Posted by exprolab View Post
    what is this? I am a learner of php. Can you describe me what is the code for?
    You're interested in learning Perl as well?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •